【问题标题】:gunicorn: ERROR (no such file) nginx + gunicorn + supervisorgunicorn:错误(没有这样的文件)nginx + gunicorn + supervisor
【发布时间】:2012-11-22 14:03:06
【问题描述】:

我使用 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)

文件丢失了什么?如何部署我的项目?

【问题讨论】:

    标签: django nginx gunicorn supervisord


    【解决方案1】:

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

    【讨论】:

    • 在我们的例子中,我们在更新配置后错过了supervisorctl reread,因此start 命令正在寻找已被删除的二进制文件。
    【解决方案2】:

    由于您使用的是 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/ 是您的 virtualenv 的路径。

    【讨论】:

    • 我编辑了 supervisord.conf 并添加了:`command=/home/user/my_project/bin/gunicorn_django -w 4 -b 127.0.0.1:9999 -t 300 --max-requests=1000 目录=/home/user/my_project/stratatech/stratatech/ 在 bin/supevisorctl start all 之后,gunicorn 启动了。但是我的网站没有在 server_name (nginx.conf) 中的地址上打开。为什么?
    • 在 nginx.conf 中更改监听 111111111:80;听:80;然后重启 nginx。
    【解决方案3】:

    我有同样的问题,实际上我发现我的虚拟环境中没有安装 gunicorn。

    pip install gunicorn==<version_number>
    

    【讨论】:

    • 更适合作为评论,因为建议安装 gunicorn 然后尝试!
    【解决方案4】:

    我从使用 apt 安装主管切换到使用 pip。这将主管和 pidproxy 的路径从 /usr/bin 更改为 /usr/local/bin/。我在主管 gunicorn.conf 中使用 pidproxy。

    所以只是切换主管安装方法意味着找不到“pidproxy”并生成消息“gunicorn: ERROR (no such file)”。

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

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

    【讨论】:

      猜你喜欢
      • 2013-10-05
      • 1970-01-01
      • 2014-03-31
      • 2013-01-06
      • 2015-04-21
      • 2019-12-05
      • 2020-12-26
      • 2016-04-23
      • 1970-01-01
      相关资源
      最近更新 更多