has anyone around here looked at the linux 'supervise' stuff to accomplish this? <br><br><a href="http://cr.yp.to/daemontools.html">http://cr.yp.to/daemontools.html</a><br><br>~s<br><br><div class="gmail_quote">On Wed, Sep 23, 2009 at 12:43 PM, Brent Pedersen <span dir="ltr"><<a href="mailto:bpederse@gmail.com">bpederse@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Wed, Sep 23, 2009 at 12:02 PM, Benjamin Sergeant <<a href="mailto:bsergean@gmail.com">bsergean@gmail.com</a>> wrote:<br>
> Hi there,<br>
><br>
> I figured out this morning that I had a long-running process that died<br>
> one week ago for some obscure reasons. I made a little script that<br>
> restarts a script when the called script die. I know there are already<br>
> existing stuff doing that but I could not remember the name / find any<br>
> existing ones ... so why not re-inventing the wheel one more time :)<br>
><br>
> Thanks for any feedback,<br>
> - Benjamin<br>
><br>
> <a href="http://code.activestate.com/recipes/576911/" target="_blank">http://code.activestate.com/recipes/576911/</a><br>
> #!/usr/bin/env python<br>
><br>
> import sys<br>
> import time<br>
> import subprocess<br>
><br>
> """<br>
> Keep a process up and running<br>
><br>
> If you have a long running process that can be killed for strange and unknown<br>
> reason, you might want it to be restarted ... this script does that.<br>
><br>
> $ cat alive.sh<br>
> #!/bin/sh<br>
><br>
> while `true`; do echo Alive && sleep 3 ; done<br>
><br>
> Use it like this:<br>
> $ keepup.py ./alive.sh<br>
> """<br>
><br>
> cmd = ' '.join(sys.argv[1:])<br>
><br>
> def start_subprocess():<br>
> return subprocess.Popen(cmd, shell=True)<br>
><br>
> p = start_subprocess()<br>
><br>
> while True:<br>
><br>
> res = p.poll()<br>
> if res is not None:<br>
> print p.pid, 'was killed, restarting it'<br>
> p = start_subprocess()<br>
><br>
> time.sleep(1)<br>
> _______________________________________________<br>
> Baypiggies mailing list<br>
> <a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
> To change your subscription options or unsubscribe:<br>
> <a href="http://mail.python.org/mailman/listinfo/baypiggies" target="_blank">http://mail.python.org/mailman/listinfo/baypiggies</a><br>
><br>
<br>
</div></div>there's also the monitor option in paste serve. check out<br>
restart_with_monitor() in<br>
<a href="http://svn.pythonpaste.org/Paste/Script/trunk/paste/script/serve.py" target="_blank">http://svn.pythonpaste.org/Paste/Script/trunk/paste/script/serve.py</a><br>
which you could crib from or use directly.<br>
<div><div></div><div class="h5">_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="http://mail.python.org/mailman/listinfo/baypiggies" target="_blank">http://mail.python.org/mailman/listinfo/baypiggies</a></div></div></blockquote></div><br>