Class: Guard::Sidekiq
Constant Summary collapse
- DEFAULT_SIGNAL =
:QUIT
- DEFAULT_CONCURRENCY =
1
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Sidekiq
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_changes(paths) ⇒ Object
Called on file(s) modifications.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Sidekiq
Allowable options are:
- :environment e.g. 'test'
- :queue e.g. 'default'
- :timeout e.g. 5
- :config e.g. config/sidekiq.yml
- :concurrency, e.g. 20
- :verbose e.g. true
- :stop_signal e.g. :QUIT or :SIGQUIT
19 20 21 22 23 24 25 26 |
# File 'lib/guard/sidekiq.rb', line 19 def initialize(watchers = [], = {}) @options = @pid = nil @stop_signal = [:stop_signal] || DEFAULT_SIGNAL @options[:concurrency] ||= DEFAULT_CONCURRENCY @options[:verbose] = @options.fetch(:verbose, true) super end |
Instance Method Details
#reload ⇒ Object
Called on Ctrl-Z signal
59 60 61 62 |
# File 'lib/guard/sidekiq.rb', line 59 def reload UI.info 'Restarting sidekiq...' restart end |
#restart ⇒ Object
74 75 76 77 |
# File 'lib/guard/sidekiq.rb', line 74 def restart stop start end |
#run_all ⇒ Object
Called on Ctrl-/ signal
65 66 67 |
# File 'lib/guard/sidekiq.rb', line 65 def run_all true end |
#run_on_changes(paths) ⇒ Object
Called on file(s) modifications
70 71 72 |
# File 'lib/guard/sidekiq.rb', line 70 def run_on_changes(paths) restart end |
#start ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/guard/sidekiq.rb', line 28 def start stop UI.info 'Starting up sidekiq...' UI.info cmd # launch Sidekiq worker @pid = spawn({}, cmd) end |
#stop ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/guard/sidekiq.rb', line 37 def stop if @pid UI.info 'Stopping sidekiq...' ::Process.kill @stop_signal, @pid begin Timeout.timeout(15) do ::Process.wait @pid end rescue Timeout::Error UI.info 'Sending SIGKILL to sidekiq, as it\'s taking too long to shutdown.' ::Process.kill :KILL, @pid ::Process.wait @pid end UI.info 'Stopped process sidekiq' end rescue Errno::ESRCH UI.info 'Guard::Sidekiq lost the Sidekiq worker subprocess!' ensure @pid = nil end |