I found a great resource here.
How can I monitor a rake task with monit?
質問
I have a rake task that I want to run forever and ever and ever. It's job is to monitor a table and process entries in that table as they occur (from another rake task that I need to monitor also).
I am already using monit to monitor a Sidekiq worker. However, I don't know what to put in the "stop" entry in the monitrc
file. The only way I would know how to kill a rake
task is with the kill
command.
How can I ensure that my two rake
tasks are restarted if they are killed or if they die?
I found a link to a list of examples, but none of them are really even close to what I need.
解決
他のヒント
Another option (if using Ruby 1.9+) is to use the "Process.spawn" and "Process.daemon" method to spawn unix processes and return their PID. This will allow you to write the monit script in ruby.