ruby - Ensure orphaned processes are killed when the parent process dies -
in ruby, how ensure child processes spawned program don't keep running when main process exits or killed?
initially thought use at_exit
in main process, won't work if main process gets kill -9
ed or calls kernel.exec
. need solution (basically) foolproof, , cross-platform.
if have handle kill -9 termination parent app, have couple of choices can see:
- create work queue manager , spawn/kill child processes work queue manager. if can't guarantee work queue manager won't killed without warning, option 2 choice think, since thing know sure child processes still running.
- http://www.celeryproject.org/
- http://aws.amazon.com/elasticbeanstalk/
- more aggressive approach - spawn off whole os instances they'll killed off within parameters operation
- have child processes check "heartbeat" parent process through rpc or monitoring parent pid in memory or watching date/time on keep-alive file in /tmp make sure it's current.
- if child processes fail see parent processes doing it's job of either responding rpc messages, staying in memory itself, or keeping file date/time current child processes must kill themselves.
Comments
Post a Comment