mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Use non-successful exit code when something goes wrong
This commit is contained in:
parent
9cf8659ef5
commit
b044170542
1 changed files with 11 additions and 7 deletions
|
@ -11,28 +11,32 @@ class Sidekiqctl
|
||||||
@pidfile = pidfile
|
@pidfile = pidfile
|
||||||
@timeout = timeout
|
@timeout = timeout
|
||||||
|
|
||||||
done 'No pidfile given' if !pidfile
|
done('No pidfile given', :error) if !pidfile
|
||||||
done "Pidfile #{pidfile} does not exist" if !File.exist?(pidfile)
|
done("Pidfile #{pidfile} does not exist", :error) if !File.exist?(pidfile)
|
||||||
done 'Invalid pidfile content' if pid == 0
|
done('Invalid pidfile content', :error) if pid == 0
|
||||||
|
|
||||||
fetch_process
|
fetch_process
|
||||||
|
|
||||||
begin
|
begin
|
||||||
send(stage)
|
send(stage)
|
||||||
rescue NoMethodError
|
rescue NoMethodError
|
||||||
done 'Invalid control command'
|
done 'Invalid control command', :error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_process
|
def fetch_process
|
||||||
Process.getpgid(pid)
|
Process.getpgid(pid)
|
||||||
rescue Errno::ESRCH
|
rescue Errno::ESRCH
|
||||||
done "Process doesn't exist"
|
done "Process doesn't exist", :error
|
||||||
end
|
end
|
||||||
|
|
||||||
def done(msg)
|
def done(msg, error = nil)
|
||||||
puts msg
|
puts msg
|
||||||
exit(0)
|
exit(exit_signal(error))
|
||||||
|
end
|
||||||
|
|
||||||
|
def exit_signal(error)
|
||||||
|
(error == :error) ? 1 : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def pid
|
def pid
|
||||||
|
|
Loading…
Add table
Reference in a new issue