Class: Guard::ResqueScheduler
- Defined in:
- lib/guard/resque-scheduler.rb
Constant Summary collapse
- DEFAULT_SIGNAL =
:QUIT
- DEFAULT_TASK =
'resque:scheduler'.freeze
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ ResqueScheduler
constructor
Allowable options are: - :environment e.g.
-
#reload ⇒ Object
Called on Ctrl-Z signal.
- #restart ⇒ Object
-
#run_all ⇒ Object
Called on Ctrl-/ signal.
-
#run_on_change(paths) ⇒ Object
Called on file(s) modifications.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ ResqueScheduler
Allowable options are:
- :environment e.g. 'test'
- :task .e.g 'resque:work'
- :verbose e.g. true
- :trace e.g. true
- :stop_signal e.g. :QUIT or :SIGQUIT
17 18 19 20 21 22 23 |
# File 'lib/guard/resque-scheduler.rb', line 17 def initialize(watchers = [], = {}) @options = @pid = nil @stop_signal = [:stop_signal] || DEFAULT_SIGNAL @options[:task] ||= DEFAULT_TASK super end |
Instance Method Details
#reload ⇒ Object
Called on Ctrl-Z signal
56 57 58 59 |
# File 'lib/guard/resque-scheduler.rb', line 56 def reload UI.info 'Restarting resque-scheduler...' restart end |
#restart ⇒ Object
71 72 73 74 |
# File 'lib/guard/resque-scheduler.rb', line 71 def restart stop start end |
#run_all ⇒ Object
Called on Ctrl-/ signal
62 63 64 |
# File 'lib/guard/resque-scheduler.rb', line 62 def run_all true end |
#run_on_change(paths) ⇒ Object
Called on file(s) modifications
67 68 69 |
# File 'lib/guard/resque-scheduler.rb', line 67 def run_on_change(paths) restart end |
#start ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/guard/resque-scheduler.rb', line 25 def start stop UI.info 'Starting up resque-scheduler...' UI.info [ cmd, env.map{|v| v.join('=')} ].join(' ') # Launch ResqueScheduler @pid = spawn(env, cmd) end |
#stop ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/guard/resque-scheduler.rb', line 34 def stop if @pid UI.info 'Stopping resque-scheduler...' ::Process.kill @stop_signal, @pid begin Timeout.timeout(15) do ::Process.wait @pid end rescue Timeout::Error UI.info 'Sending SIGKILL to resque-scheduler, as it\'s taking too long to shutdown.' ::Process.kill :KILL, @pid ::Process.wait @pid end UI.info 'Stopped process resque-scheduler' end rescue Errno::ESRCH UI.info 'Guard::ResqueScheduler lost the ResqueScheduler worker subprocess!' ensure @pid = nil end |