diff --git a/Changes.md b/Changes.md index ef0e1841d..3d27ea05c 100644 --- a/Changes.md +++ b/Changes.md @@ -3,6 +3,7 @@ HEAD - Log Sidekiq Pro's Batch ID if available [#2076] - Refactor Processor Redis usage to avoid redis/redis-rb#490 [#] +- Add better usage text for `sidekiqctl`. 3.3.0 diff --git a/bin/sidekiqctl b/bin/sidekiqctl index 1c62e1b5e..7ad5f77a7 100755 --- a/bin/sidekiqctl +++ b/bin/sidekiqctl @@ -3,23 +3,29 @@ require 'fileutils' class Sidekiqctl - DEFAULT_TIMEOUT = 10 + DEFAULT_KILL_TIMEOUT = 10 - attr_reader :stage, :pidfile, :timeout + attr_reader :stage, :pidfile, :kill_timeout def self.print_usage + puts "#{File.basename($0)} - stop a Sidekiq process from the command line." puts - puts "Usage: #{File.basename($0)} " - puts " where is either 'quiet', 'stop' or 'shutdown'" + puts "Usage: #{File.basename($0)} " + puts " where is either 'quiet' or 'stop'" puts " is path to a pidfile" - puts " is number of seconds to wait till Sidekiq exits (default: #{Sidekiqctl::DEFAULT_TIMEOUT})" + puts " is number of seconds to wait until Sidekiq exits" + puts " (default: #{Sidekiqctl::DEFAULT_KILL_TIMEOUT}), after which Sidekiq will be KILL'd" + puts + puts "Be sure to set the kill_timeout LONGER than Sidekiq's -t timeout. If you want" + puts "to wait 60 seconds for jobs to finish, use `sidekiq -t 60` and `sidekiqctl stop" + puts " path_to_pidfile 61`" puts end def initialize(stage, pidfile, timeout) @stage = stage @pidfile = pidfile - @timeout = timeout + @kill_timeout = timeout done('No pidfile given', :error) if !pidfile done("Pidfile #{pidfile} does not exist", :warn) if !File.exist?(pidfile) @@ -30,7 +36,7 @@ class Sidekiqctl begin send(stage) rescue NoMethodError - done 'Invalid control command', :error + done "Invalid command: #{stage}", :error end end @@ -59,7 +65,7 @@ class Sidekiqctl def stop `kill -TERM #{pid}` - timeout.times do + kill_timeout.times do begin Process.getpgid(pid) rescue Errno::ESRCH @@ -72,11 +78,7 @@ class Sidekiqctl FileUtils.rm_f pidfile done 'Sidekiq shut down forcefully.' end - - def shutdown - quiet - stop - end + alias_method :shutdown, :stop end if ARGV.length < 2 @@ -85,7 +87,7 @@ else stage = ARGV[0] pidfile = ARGV[1] timeout = ARGV[2].to_i - timeout = Sidekiqctl::DEFAULT_TIMEOUT if timeout == 0 + timeout = Sidekiqctl::DEFAULT_KILL_TIMEOUT if timeout == 0 Sidekiqctl.new(stage, pidfile, timeout) end diff --git a/lib/sidekiq/manager.rb b/lib/sidekiq/manager.rb index 4bbb6bd9c..87580a4e6 100644 --- a/lib/sidekiq/manager.rb +++ b/lib/sidekiq/manager.rb @@ -48,7 +48,7 @@ def stop(options={}) @done = true - logger.info { "Shutting down #{@ready.size} quiet workers" } + logger.info { "Terminating #{@ready.size} quiet workers" } @ready.each { |x| x.terminate if x.alive? } @ready.clear