Class: Guard::Nginx
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Nginx
- Defined in:
- lib/guard/nginx.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Nginx
constructor
A new instance of Nginx.
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_change(_paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Nginx
Returns a new instance of Nginx.
9 10 11 12 13 |
# File 'lib/guard/nginx.rb', line 9 def initialize() UI.info "hello path: #{Dir.pwd}" Dir.mkdir("#{tmp_path}/config") unless Dir.exist?("#{tmp_path}/config") super end |
Instance Method Details
#reload ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/guard/nginx.rb', line 34 def reload UI.info 'reload' if pid generate_config UI.info "Sending HUP signal to Nginx (reloading #{pid})" ::Process.kill('HUP', pid) true end end |
#run_all ⇒ Object
45 46 47 |
# File 'lib/guard/nginx.rb', line 45 def run_all reload end |
#run_on_change(_paths) ⇒ Object
49 50 51 |
# File 'lib/guard/nginx.rb', line 49 def run_on_change(_paths) true end |
#start ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/guard/nginx.rb', line 15 def start # ensure config - create tmp file UI.info "Starting Nginx on port #{port}" generate_config IO.popen("#{executable} -c #{tmp_path}/config/nginx.conf", 'w+') UI.info 'Nginx started' if $CHILD_STATUS.success? end |
#stop ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/guard/nginx.rb', line 24 def stop puts pid if pid UI.info "Sending TERM signal to Nginx (#{pid})" FileUtils.rm "#{tmp_path}/config/nginx.conf" ::Process.kill('TERM', pid) true end end |