KeepRunning
You can run but you can’t hide.
KeepRunning restarts a Ruby script whenever it stops, crashes or is killed.
There’s two modes to use KeepRunning: Using the keep_running
bin with a config file (see example_runner_conf) or using a KeepRunning script (see example_runner_script). The only difference is a shebang line and a require line in the KeepRunning script. (Actually the script could as well being used as configuration file; This isn’t true the other way round)
The invokation would look like this:
keep_running example_runner_conf one two three
./example_runner_script one two three
All further arguments will be passed to the process to be run. For the process running $0
will be it’s own path. So basically if your Ruby script works on it’s own, it’s scriptname $0
and command line arguments ARGV
will be the same when launched by KeepRunning.
Synopsis
A runner config would look like this:
KeepRunning.run do
pidfile '/tmp/keep_running_example'
email to: 'keep_running_test@trash-mail.com', from: 'keep_running_test@trash-mail.com', via: :sendmail
restart_threshold 6
restart_delay 60
process 'example_script.rb'
end
restart_threshold
defines how many seconds must be between restarts until a delay of restart_delay
seconds is kicking in.
Caveats
This is a quick and dirty hack. Specs will follow soon.