Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shutdown CherryPy

Tags:

cherrypy

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?

like image 460
Randy Tang Avatar asked Sep 05 '25 16:09

Randy Tang


1 Answers

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.

like image 92
saaj Avatar answered Sep 07 '25 16:09

saaj