Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - Supervisor : exited too quickly

I try to deploy my website in Django+Supervisor+NGINX on Ubuntu server 16.04.

Here is my .conf (supervisor):

[program:sitepro]
command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
user = user
autostart = true
autorestart = true

My NGINX config file :

server {
    listen      80;
    server_name .mywebsite.fr;
    charset     utf-8;
    root /home/user/sitepro/site/sitepro;
    access_log /home/user/sitepro/site/logs/nginx/access.log;
    error_log /home/user/sitepro/site/logs/nginx/error.log;

    location /static {
        alias /home/user/sitepro/site/static;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
        proxy_pass http://127.0.0.1:8002;
    }
}

When I try to launch gunicorn on the root of my project, everything goes right :

(sitepro) user@mybps:~/sitepro/site$ gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
[2017-11-01 16:09:37 +0000] [1920] [INFO] Starting gunicorn 19.7.1
[2017-11-01 16:09:37 +0000] [1920] [INFO] Listening at: http://79.137.39.12:8002 (1920)
[2017-11-01 16:09:37 +0000] [1920] [INFO] Using worker: sync
[2017-11-01 16:09:37 +0000] [1925] [INFO] Booting worker with pid: 1925

I've done a supervisorctrl reread and update (worked). And if I make supervisorctl status sitepro

sitepro                          FATAL     Exited too quickly (process log may have details)

And if I access my website I've got the "Welcome to Nginx" default page.

I've tried many tutorials for deploy django : I'm lost and tried many things. Could someone give me a simple and fast tutorial to deploy Django that he used for his propre needings please ?

Thanks !

like image 694
Arthur C-G Avatar asked Nov 01 '17 15:11

Arthur C-G


2 Answers

The issue is that you are missing the directory=... in your config file

[program:sitepro]
command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
directory = /home/user/sitepro/site
user = user
autostart = true
autorestart = true

Otherwise gunicorn will not know where to find sitepro.wsgi:application

like image 55
Tarun Lalwani Avatar answered Oct 22 '22 16:10

Tarun Lalwani


To see what is going on, you should log the supervisor output.

To do that, open the supervisor .conf file, and add the following lines:

stdout_logfile={Path}
stderr_logfile={Path}
autostart=true
autorestart=true
startsecs=10

A possible {Path} could be /home/{youruser}/sitepro.log

Restart supervisor

supervisorctl restart sitepro

Once restarted, go to the log and tell us what you see.

like image 29
Daniel Julian Avatar answered Oct 22 '22 16:10

Daniel Julian