部署CherryPy(守护进程)
我遵循了基本的CherryPy教程( http://www.cherrypy.org/wiki/CherryPyTutorial )。一个没有讨论的事情是部署。
I've followed the basic CherryPy tutorial (http://www.cherrypy.org/wiki/CherryPyTutorial). One thing not discussed is deployment.
如何将CherryPy应用程序作为守护进程启动并忘记?如果服务器重新启动,会发生什么?
How can I launch a CherryPy app as a daemon and "forget about it"? What happens if the server reboots?
是否有标准配方?可能会创建一个服务脚本(/etc/init.d/cherrypy ...)
Is there a standard recipe? Maybe something that will create a service script (/etc/init.d/cherrypy...)
谢谢!
有一个守护程序的CherryPy插件默认包含,这对于启动它是有用的,但到目前为止,简单的例子最简单的方法是使用cherryd脚本:
There is a Daemonizer plugin for CherryPy included by default which is useful for getting it to start but by far the easiest way for simple cases is to use the cherryd script:
> cherryd -h
Usage: cherryd [options]
Options:
-h, --help show this help message and exit
-c CONFIG, --config=CONFIG
specify config file(s)
-d run the server as a daemon
-e ENVIRONMENT, --environment=ENVIRONMENT
apply the given config environment
-f start a fastcgi server instead of the default HTTP
server
-s start a scgi server instead of the default HTTP server
-i IMPORTS, --import=IMPORTS
specify modules to import
-p PIDFILE, --pidfile=PIDFILE
store the process id in the given file
就一个init.d脚本而言,我认为有可能是Google的示例。
As far as an init.d script goes I think there are examples that can be Googled.
而 cherryd
存在于您的
virtualenv /lib/python2.7/site-packages/cherrypy/cherryd
virtualenv/lib/python2.7/site-packages/cherrypy/cherryd
或在: https://bitbucket.org/cherrypy/cherrypy/src/default/cherrypy/cherryd