I created the following function to shutdown cherrypy
:
import cherrypy
cherrypy.engine.exit()
Name of the file: shutdown.py
. And then I enter the command python shutdown.py
in the command line. The following messages showed up:
[06/Sep/2014:11:28:22] ENGINE Bus STOPPING
[06/Sep/2014:11:28:22] ENGINE HTTP Server None already shut down
[06/Sep/2014:11:28:22] ENGINE No thread running for None.
[06/Sep/2014:11:28:22] ENGINE No thread running for None.
[06/Sep/2014:11:28:22] ENGINE Bus STOPPED
[06/Sep/2014:11:28:22] ENGINE Bus EXITING
[06/Sep/2014:11:28:22] ENGINE Bus EXITED
However, CherryPy is still running. How do I shutdown CherryPy then?
Also, what if I have multiple cherrypy servers running at the same time? Does the shutdown.py
kill all of them?
CherryPy application is contained in ordinary Python process. To treat CherryPy application like a server (e.g. mysql, nginx, etc. which you can /etc/init.d/mysql stop
) you should deploy it accordingly.
For an ad-hoc case, just tell cherryd to save pid file with --pidfile
or integrate PIDFile plugin
into your code directly. Then just kill `cat /path/to/pidfile`
.
For a full-blown deployment read this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With