On 2011-09-02 11:27 -0700, Bruce Eckel wrote:
> If I want to shut down the web.py server, what's the appropriate way?
> Thanks...
I think you can use sys.exit[1] if you want to do it programmatically.
There's also a neat module `signal`, which can be used to handle the
SIGTERM and gracefully shut down the server if you need to clean
something up.
Here's the code:
def onterm(signum, frame):
print 'Received signal %s' % signum
// e.g., remove PID file:
os.remove(config.proc['pidfile'])
// Exit with status 0
sys.exit(0)
signal.signal(signal.SIGTERM, onterm)
I'm not sure about web.py, but I think it should work. I've used the
above pattern to run bottle app as system service[2].
[1] http://docs.python.org/library/sys.html#sys.exit
[2] http://www.brankovukelic.com/post/2743988069
--
Branko Vukelic
[email protected]
[email protected]
IDEA MACHINE
www.brankovukelic.com
Lead Developer
Herd Hound (tm) - Travel that doesn't bite
www.herdhound.com
Love coffee? You might love Loveffee, too.
loveffee.appspot.com
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.