使用Nginx部署Django作为服务

mik*_*725 1 deployment django ubuntu webserver nginx

目前我有一个运行nginx的家庭服务器(Ubuntu),我在其中使用代理传递以将请求传递给django.我使用gevent作为我的wsgi服务器.

一切正常,直到服务器关闭,因为我因任何原因重启服务器或崩溃(电).由于nginx是一项服务,当服务器重新启动时,nginx也会启动.但是我的django应用程序没有.那么我必须手动去我的每个django项目,激活他们的virtualenvs,然后启动gevent进程.至少可以说这非常烦人.

是否有自动处理所有这些的标准方法?

Chr*_*att 7

您需要为UpstartSupervisor等设置脚本.就个人而言,我更喜欢使用主管.这是我用来运行gunicorn实例的脚本:

[program:gunicorn]
command=/path/to/virtualenv/bin/python manage.py run_gunicorn -c /path/to/gunicorn.conf.py
directory=/path/to/django/project
user=www-data
autostart=true
autorestart=true
redirect_stderr=True
Run Code Online (Sandbox Code Playgroud)