#902: cherryd script doesn't respawn correctly in daemon mode
---------------------------------------+------------------------------------
Reporter:
cher...@robince.ftml.net | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Keywords: cherryd
---------------------------------------+------------------------------------
I am using CherryPy-3.1.1-py2.5.egg installed via easy_install on Ubuntu.
I am using Cherrypy as a wsgi server, and am trying to daemonise it using
cherryd. I am using paste.URLParser to dynamically dispatch to files on
disk.
If I remove a file that has already been accessed the following happens if
cherryd is started non-daemonised:
{{{
robince@penguin:~/webs$ ./cherryd -i cherrymain
[09/Feb/2009:23:54:08] ENGINE Listening for SIGHUP.
[09/Feb/2009:23:54:08] ENGINE Listening for SIGTERM.
[09/Feb/2009:23:54:08] ENGINE Listening for SIGUSR1.
[09/Feb/2009:23:54:08] ENGINE Bus STARTING
[09/Feb/2009:23:54:08] ENGINE Started monitor thread '_TimeoutMonitor'.
[09/Feb/2009:23:54:08] ENGINE Started monitor thread 'Autoreloader'.
[09/Feb/2009:23:54:08] ENGINE Serving on
0.0.0.0:8001
[09/Feb/2009:23:54:08] ENGINE Bus STARTED
[09/Feb/2009:23:54:34] ENGINE Restarting because /home/robince/webs/sum.py
changed.
[09/Feb/2009:23:54:34] ENGINE Stopped thread 'Autoreloader'.
[09/Feb/2009:23:54:34] ENGINE Bus STOPPING
[09/Feb/2009:23:54:34] ENGINE HTTP Server
cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8001)) shut down
[09/Feb/2009:23:54:34] ENGINE Stopped thread '_TimeoutMonitor'.
[09/Feb/2009:23:54:34] ENGINE Bus STOPPED
[09/Feb/2009:23:54:34] ENGINE Bus EXITING
[09/Feb/2009:23:54:34] ENGINE Bus EXITED
[09/Feb/2009:23:54:34] ENGINE Waiting for child threads to terminate...
[09/Feb/2009:23:54:34] ENGINE Re-spawning ./cherryd -i cherrymain
[09/Feb/2009:23:54:34] ENGINE Listening for SIGHUP.
[09/Feb/2009:23:54:34] ENGINE Listening for SIGTERM.
[09/Feb/2009:23:54:34] ENGINE Listening for SIGUSR1.
[09/Feb/2009:23:54:34] ENGINE Bus STARTING
[09/Feb/2009:23:54:34] ENGINE Started monitor thread '_TimeoutMonitor'.
[09/Feb/2009:23:54:34] ENGINE Started monitor thread 'Autoreloader'.
[09/Feb/2009:23:54:34] ENGINE Serving on
0.0.0.0:8001
[09/Feb/2009:23:54:34] ENGINE Bus STARTED
}}}
So it seems like the change to the file is detected and the server
respawns.
However, if I start it with the -d flag, I get the following log:
{{{
robince@penguin:~/webs$ cat cp_error.log
[09/Feb/2009:23:58:13] ENGINE Listening for SIGHUP.
[09/Feb/2009:23:58:13] ENGINE Listening for SIGTERM.
[09/Feb/2009:23:58:13] ENGINE Listening for SIGUSR1.
[09/Feb/2009:23:58:13] ENGINE Bus STARTING
[09/Feb/2009:23:58:13] ENGINE Forking once.
[09/Feb/2009:23:58:13] ENGINE Daemonized to PID: 32411
[09/Feb/2009:23:58:13] ENGINE Forking twice.
[09/Feb/2009:23:58:13] ENGINE Started monitor thread '_TimeoutMonitor'.
[09/Feb/2009:23:58:13] ENGINE Started monitor thread 'Autoreloader'.
[09/Feb/2009:23:58:13] ENGINE Serving on
0.0.0.0:8001
[09/Feb/2009:23:58:13] ENGINE Bus STARTED
[09/Feb/2009:23:59:40] ENGINE Restarting because /home/robince/webs/sum.py
changed.
[09/Feb/2009:23:59:40] ENGINE Stopped thread 'Autoreloader'.
[09/Feb/2009:23:59:40] ENGINE Bus STOPPING
[09/Feb/2009:23:59:40] ENGINE HTTP Server
cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8001)) shut down
[09/Feb/2009:23:59:40] ENGINE Stopped thread '_TimeoutMonitor'.
[09/Feb/2009:23:59:40] ENGINE Bus STOPPED
[09/Feb/2009:23:59:40] ENGINE Bus EXITING
[09/Feb/2009:23:59:40] ENGINE Bus EXITED
[09/Feb/2009:23:59:40] ENGINE Waiting for child threads to terminate...
[09/Feb/2009:23:59:40] ENGINE Re-spawning ./cherryd -d -i cherrymain
}}}
But it doesn't respawn. The server is just shut down - there is no longer
any Python running.