我使用gunicorn,nginx,supervisord部署我的django项目。我在virtualenv中安装了一个gunicorn,并在INSTALL_APPS中添加了。命令./manage.py run_gunicorn -b 127.0.0.1:8999起作用:
2012-12-04 12:27:33 [21917] [INFO] Starting gunicorn 0.16.1
2012-12-04 12:27:33 [21917] [INFO] Listening at: http://127.0.0.1:8999 (21917)
2012-12-04 12:27:33 [21917] [INFO] Using worker: sync
2012-12-04 12:27:33 [22208] [INFO] Booting worker with pid: 22208对于nginx,我编辑了nginx.conf:
server {
listen 111111111:80;
server_name my_site.pro;
access_log /home/user/logs/nginx_access.log;
error_log /home/user/logs/nginx-error.log;
location /static/ {
alias /home/user/my_project/static/;
}
location /media/ {
alias /home/user/my_project/media/;
}
location / {
proxy_pass http://127.0.0.1:8999;
include /etc/nginx/proxy.conf;
}
}之后,我重新启动了nginx。
supervisord.conf:
[unix_http_server]
file=/tmp/supervisor-my_project.sock
chmod=0700
chown=user:user
[supervisord]
logfile=/home/user/logs/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord-my_project.pid
nodaemon=false
minfds=1024
minprocs=200
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor-my_project.sock
[program:gunicorn]
command=/home/user/bin/manage run_gunicorn -w 4 -b 127.0.0.1:8999 -t 300 --max- requests=1000
startsecs=10
stopwaitsecs=60
redirect_stderr=true
stdout_logfile=/home/user/gunicorn.log我运行了bin/supervisorctl start all。但是我得到了:
gunicorn: ERROR (no such file)文件丢失了什么?如何部署我的项目?
发布于 2013-10-11 07:08:03
对于将来的搜索者,我遇到了这个问题,问题是我需要提供Gunicorn二进制文件的完整路径。无论出于什么原因,即使使用指定的PATH=环境变量,supervisor也无法找到该二进制文件。一旦我/full_path/gunicorn成功了。(也许有一种方法可以通过环境变量正确地做到这一点)
发布于 2012-12-05 05:28:12
由于您使用的是virtualenv,因此必须将环境设置为它在supervisord.conf中使用的路径。
试试这个:
[program:gunicorn]
command=/home/user/bin/manage run_gunicorn -w 4 -b 127.0.0.1:8999 -t 300 --max-requests=1000
environment=PATH="/home/user/bin/"
...这里假设/home/user/bin/是你的虚拟环境的路径。
发布于 2015-11-02 14:01:00
我也有同样的问题,实际上我发现我的虚拟环境中没有安装黑角兽。
做
pip install gunicorn==<version_number>https://stackoverflow.com/questions/13711486
复制相似问题