为django守护樱桃服务器

时间:2014-12-17 13:22:08

标签: django cherrypy

我正在使用CherryPy服务器来部署Django。具体来说,我使用的是here指令。这可以方便地将Cherrypy服务器打包在Django manage.py命令中,并提供以下选项:

root@appportal /home/Protrak# ./manage.py runcpserver help

Run this project in a CherryPy webserver. To do this, CherryPy from
http://www.cherrypy.org/ is required.

 runcpserver [options] [cpserver settings] [stop]

Optional CherryPy server settings: (setting=value)
host=HOSTNAME         hostname to listen on
                      Defaults to localhost
port=PORTNUM          port to listen on
                      Defaults to 8088
server_name=STRING    CherryPy's SERVER_NAME environ entry
                      Defaults to localhost
daemonize=BOOL        whether to detach from terminal
                      Defaults to False
pidfile=FILE          write the spawned process-id to this file
workdir=DIRECTORY     change to this directory when daemonizing
threads=NUMBER        Number of threads for server to use
ssl_certificate=FILE  SSL certificate file
ssl_private_key=FILE  SSL private key file
server_user=STRING    user to run daemonized process
                      Defaults to www-data
server_group=STRING   group to daemonized process
                      Defaults to www-data

Examples:
  Run a "standard" CherryPy server server
  $ manage.py runcpserver

  Run a CherryPy server on port 80
  $ manage.py runcpserver port=80

  Run a CherryPy server as a daemon and write the spawned PID in a file
  $ manage.py runcpserver daemonize=true pidfile=/var/run/django-cpserver.pid

我按如下方式运行此服务器:

root@appportal /home/Protrak# ./manage.py runcpserver host=0.0.0.0

并且它的工作原理非常好。但是,我尝试按如下方式将其守护:

root@appportal /home/Protrak# ./manage.py runcpserver host=0.0.0.0 daemonize=True

它只是从终端断开连接,但没有后台进程产生。我既不能访问该站点,也不能将其视为服务器上的进程。我做错了什么?

1 个答案:

答案 0 :(得分:0)

创建守护程序进程时,PYTHONPATH可能存在错误。

修改插件的代码(您下载的代码),将日志参数(out_logerr_log)添加到行202上的守护程序调用和{{1 } 204,它使用django function become_daemon

这将帮助您调试错误。