diff --git a/bin/sidekiqctl b/bin/sidekiqctl index 26268ac9..1c62e1b5 100755 --- a/bin/sidekiqctl +++ b/bin/sidekiqctl @@ -3,9 +3,19 @@ require 'fileutils' class Sidekiqctl + DEFAULT_TIMEOUT = 10 attr_reader :stage, :pidfile, :timeout + def self.print_usage + puts + puts "Usage: #{File.basename($0)} " + puts " where is either 'quiet', 'stop' or 'shutdown'" + puts " is path to a pidfile" + puts " is number of seconds to wait till Sidekiq exits (default: #{Sidekiqctl::DEFAULT_TIMEOUT})" + puts + end + def initialize(stage, pidfile, timeout) @stage = stage @pidfile = pidfile @@ -67,12 +77,15 @@ class Sidekiqctl quiet stop end - end -stage = ARGV[0] -pidfile = ARGV[1] -timeout = ARGV[2].to_i -timeout = 10 if timeout == 0 +if ARGV.length < 2 + Sidekiqctl.print_usage +else + stage = ARGV[0] + pidfile = ARGV[1] + timeout = ARGV[2].to_i + timeout = Sidekiqctl::DEFAULT_TIMEOUT if timeout == 0 -Sidekiqctl.new(stage, pidfile, timeout) + Sidekiqctl.new(stage, pidfile, timeout) +end