Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gunicorn: ERROR (no such file) nginx + gunicorn + supervisor

I deploy my django project with gunicorn, nginx, supervisord. I installed a gunicorn in virtualenv, added in INSTALL_APPS. The command ./manage.py run_gunicorn -b 127.0.0.1:8999 works:

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

For nginx I edited 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;
    }
}

After that I restarted 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

I ran bin/supervisorctl start all. But I got:

gunicorn: ERROR (no such file)

What the file is missing? How can I deploy my project?

like image 506
Olga Avatar asked Dec 04 '12 20:12

Olga


3 Answers

For future searchers, I had this problem and the issue was that I needed to provide a full path to the Gunicorn binary. For whatever reason, even with the PATH= environment variable specified supervisor couldn't find the binary. Once I /full_path/gunicorn it worked. (Maybe there's a way to do this correctly with environment variables)

like image 167
rogueleaderr Avatar answered Nov 07 '22 22:11

rogueleaderr


Since you are using virtualenv you must set the environment to the PATH used by it in supervisord.conf.

Try this:

[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/"
...

This is assuming /home/user/bin/ is the path to your virtualenv.

like image 31
jordanvg Avatar answered Nov 07 '22 23:11

jordanvg


I had same issue, actually I found out there is no gunicorn installed in my virtual environment.

Do

pip install gunicorn==<version_number>
like image 1
Sreedhar Avatar answered Nov 07 '22 22:11

Sreedhar