Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Keeping children alive persistiently, intelligentlyby peterdragon (Beadle) |
on Feb 09, 2008 at 09:21 UTC ( [id://667158]=note: print w/replies, xml ) | Need Help?? |
POE is a good choice for the parent. It makes it easy to write event-driven code that handles state changes and timed events.
POE is single threaded, however, so you definitely need to fork() any workers that might block. There's some example start/stop code at Re: Perl Background processes in Windows. Remove the setsid() call from that and the children will stay in the parent process group and die when it does. You should also consider what you're doing with Stdin/Stdout/Stderr in the child processes - going to parent's tty, or to log file or /dev/null? Also if you interrupt with CTRL-C you probably need tidy up code. Following is an example of using POE to control start/stop. You would need to make it more sophisticated to handle your rules for the list of parameters and the respawn intervals. E.g. stash the date/time of last exit against entries in your list and take account of that in the spawner.
Regards, Peter
-- peterdragon
In Section
Seekers of Perl Wisdom
|
|