[英]Django - Deployment with Gunicorn, Nginx and Supervisor, Gunicorn error log
[英]gunicorn: ERROR (no such file) nginx + gunicorn + supervisor
我使用 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)
缺少什么文件? 如何部署我的項目?
對於未來的搜索者,我遇到了這個問題,問題是我需要提供 Gunicorn 二進制文件的完整路徑。 無論出於何種原因,即使指定了 PATH= 環境變量,主管也找不到二進制文件。 一旦我 /full_path/gunicorn 它就起作用了。 (也許有一種方法可以使用環境變量正確執行此操作)
由於您使用的是 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 的路徑。
我有同樣的問題,實際上我發現我的虛擬環境中沒有安裝 gunicorn。
做
pip install gunicorn==<version_number>
我從使用 apt 安裝主管切換到使用 pip。 這將 supervisor 和 pidproxy 的路徑從 /usr/bin 更改為 /usr/local/bin/。 我在我的主管 gunicorn.conf 中使用 pidproxy。
所以只是切換主管安裝方法意味着找不到“pidproxy”並生成消息“gunicorn:錯誤(沒有這樣的文件)”。
糟糕的錯誤消息可能指的是 gunicorn 以外的東西。
命令=/usr/local/bin/pidproxy /var/run/gunicorn.pid /gunicorn.sh
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.