monitoring/restarting an application

Ghirai ghirai at ghirai.com
Thu Mar 5 09:37:00 EST 2009


Hello list,

I need to keep x number of instances of an external applications
running, say /bin/x, but also kill and restart each one after y seconds.

What would be the best way to do this (with python 2.5.x)?

I'm thinking of having a list of running pids, then have a thread check
if len(list) < x, and if it is, then start a new process (with
os.spawnv?) and add it to the list.
Also in the list i'd keep PIDs and some sort of started-timestamp, so i
know which to kill.

Does this sound reasonable, or is there an easier way?

Thanks.

-- 
Regards,
Ghirai.



More information about the Python-list mailing list