gunicorn: 错误(没有这个文件)nginx + gunicorn + supervisor

10

我使用gunicorn、nginx和supervisord部署我的django项目。我在虚拟环境中安装了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)

文件缺失了什么?我该如何部署我的项目?
4个回答

14

对于未来的搜索者,我遇到了这个问题,问题是我需要提供Gunicorn二进制文件的完整路径。由于某种原因,即使指定了PATH=环境变量,supervisor也找不到二进制文件。一旦我使用/full_path/gunicorn它就可以工作了。(也许有一种方法可以使用环境变量来正确解决这个问题)


2
在我们的情况下,在更新配置后,我们错过了 supervisorctl reread 命令,因此 start 命令正在寻找已被删除的二进制文件。 - cmbuckley

1

由于您正在使用virtualenv,因此必须在supervisord.conf中将环境设置为其使用的PATH。

请尝试以下操作:

[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/是您的虚拟环境路径。


我编辑了supervisord.conf并添加了以下内容:command=/home/user/my_project/bin/gunicorn_django -w 4 -b 127.0.0.1:9999 -t 300 --max-requests=1000 directory=/home/user/my_project/stratatech/stratatech/ 然后运行bin/supevisorctl start all,gunicorn已经启动。但是我的网站在server_name(nginx.conf)中的地址上无法打开。为什么? - Olga
在nginx.conf中将listen 111111111:80;更改为listen:80;,然后重新启动nginx。 - jordanvg

1

我遇到了同样的问题,后来发现我的虚拟环境中没有安装gunicorn。

执行以下操作:

pip install gunicorn==<version_number>

更适合作为注释,因为它建议安装 gunicorn 然后尝试! - CinCout

0

我从使用apt安装supervisor转为使用pip。这将supervisor和pidproxy的路径从/usr/bin更改为/usr/local/bin/。在我的supervisor gunicorn.conf中,我使用pidproxy。

因此,仅仅切换supervisor的安装方法意味着找不到“pidproxy”,并生成了“gunicorn: ERROR(no such file)”的错误消息。

糟糕的错误消息可能指的是gunicorn以外的其他东西。

command=/usr/local/bin/pidproxy /var/run/gunicorn.pid /gunicorn.sh


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接