The following setup is only letting me see the default Nginx html page. How can I get to Django?
I've been following Linode's documentation on how to set this up (and numerous other tutorials), but they don't use systemd, so things are a bit different.
https://www.linode.com/docs/websites/nginx/deploy-django-applications-using-uwsgi-and-nginx-on-ubuntu-14-04
I am using Linode with Fedora24. I have installed my virutalenv at
/home/ofey/djangoenv and activated it,
Django is installed using pip at
/home/ofey/qqiProject
Into the virtualenv I've installed uwsgi.
Firstly,
/etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStart=/home/ofey/djangoenv/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
This executes,
/etc/uwsgi/sites/qqiProject.ini
[uwsgi]
project = qqiProject
base = /home/ofey
chdir = %(base)/%(project)
home = %(base)/djangoenv
module = %(project).wsgi:application
master = true
processes = 2
socket = %(base)/%(project)/%(project).sock
chmod-socket = 664
vacuum = true
Also,
/etc/nginx/sites-available/qqiProject
server {
listen 80;
server_name qqiresources.com www.qqiresources.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/qqiProject;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/django/qqiProject/qqiProject.sock;
}
}
The file /etc/nginx/nginx.conf has not been changed.
The user is ofey, I've used,
$ sudo systemctl daemon-reload
$ sudo systemctl restart nginx
$ sudo systemctl start uwsgi.service
Started Django with,
$ python manage.py runserver
To Django's settings.py I turned off debugging and added a host
DEBUG = False
ALLOWED_HOSTS = ['qqiresources.com']
I have also created a symbolic link,
sudo ln -s /etc/nginx/sites-available/qqiProject /etc/nginx/sites-enabled
Any help would be greatly appreciated,
Thanks
The following is working for me, however I am not sure if this is the correct or most efficient way to do it, especially where the sockets are concerned.
systemd runs the uwsgi.service and can be started with,
$ sudo systemctl start uwsgi.service
Sometimes it is necessary to reload systemd using,
$ sudo systemctl daemon-reload
/etc/sysemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStart=/home/ofey/djangoenv/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
This calls the binary inside my django virtual environment directory with,
ExecStart=/home/ofey/djangoenv/bin/uwsgi
and also takes us to /etc/uwsgi/sites where the uwsgi configuration files is called djangoForum.ini
/etc/uwsgi/sites/djangoForum.ini
[uwsgi]
project = djangoForum
base = /home/ofey
chdir = %(base)/%(project)
home = %(base)/djangoenv
module = crudProject.wsgi:application
master = true
processes = 2
socket = 127.0.0.1:3031
chmod-socket = 664
vacuum = true
Django is at /home/ofey/djangoForum and my django project is at /home/ofey/djangoForum/crudProject
/etc/nginx/nginx.conf
events {
worker_connections 1024;
}
http{
upstream django {
# connect to this socket
# server unix:///tmp/uwsgi.sock; # for a file socket
server 127.0.0.1:3031; # for a web port socket
}
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name example.com; # substitute your machine's IP address or FQDN
charset utf-8;
#Max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/ofey/djangoForum/fileuploader/uploaded_files; # your Django project's media files
}
location /static {
alias /home/ofey/djangoForum/noAppBoundStaticDirectory; # your Django project's static files
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
# uwsgi_pass 127.0.0.1:3031;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
}
nginx can be turned on with,
$ sudo systemctl start nginx.service
'start' can be replaced with, 'restart' or 'stop'.
These configuration files for uwsgi and nginx worked for me.
Useful links:
https://gist.github.com/evildmp/3094281
https://www.linode.com/docs/websites/nginx/deploy-django-applications-using-uwsgi-and-nginx-on-ubuntu-14-04
Related
I am attempting to setup a DigitalOcean Droplet to hold a Django application, and I am following this overview: https://simpleisbetterthancomplex.com/tutorial/2016/10/14/how-to-deploy-to-digital-ocean.html
The application runs fine when I execute it via: python manage.py runserver 0.0.0.0:8000
However, once the application is started via sudo supervisorctl restart all and I run sudo supervisorctl status, I get this, but the app doesn't work when I got to the correct URL:
site#SiteDroplet:~$ sudo supervisorctl status Site
Site RUNNING pid 3071, uptime 0:00:19
Can someone help?
Here is my directory structure:
site#SiteDroplet:~$ cd ../
site#SiteDroplet:/home$ cd ../
site#SiteDroplet:/$ ls
bin dev home initrd.img.old lib64 media opt root sbin srv tmp var vmlinuz.old
boot etc initrd.img lib lost+found mnt proc run snap sys usr vmlinuz
site#SiteDroplet:/$ ^C
site#SiteDroplet:/$ cd home
site#SiteDroplet:/home$ ls
site
site#SiteDroplet:/home$ cd site
site#SiteDroplet:~$ ls
Site bin include lib local logs run share
site#SiteDroplet:~$ cd bin
site#SiteDroplet:~/bin$ ls
activate activate.fish easy_install gunicorn_start pip2 python python2 wheel
activate.csh activate_this.py easy_install-2.7 pip pip2.7 python-config python2.7
site#SiteDroplet:~/bin$ cd ../
site#SiteDroplet:~$ cd Site
site#SiteDroplet:~/Site$ ls
Site app.yaml forms interface_login interface_management interface_resident interface_security objects requirements.txt utils
README.md cron.yaml interface_admin interface_maintenance interface_onsite interface_root manage.py objects_client templates
site#SiteDroplet:~/Site$ Site is my Django Project Directory
Here is my gunicorn_start file
#!/bin/bash
NAME="Site"
DIR=/home/site/Site
USER=site
GROUP=site
WORKERS=3
BIND=unix:/home/site/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=Site.settings
DJANGO_WSGI_MODULE=Site.wsgi
LOG_LEVEL=error
cd $DIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ../bin/gunicorn_start ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-
Here is my supervisor config
[program:Site]
command=/home/site/bin/gunicorn_start
user=site
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/site/logs/gunicorn-error.log
Nginix config
upstream app_server {
server unix:/home/site/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
# add here the ip address of your server
# or a domain pointing to that ip (like example.com or www.example.com)
server_name 157.230.230.54;
keepalive_timeout 5;
client_max_body_size 4G;
access_log /home/site/logs/nginx-access.log;
error_log /home/site/logs/nginx-error.log;
location /static/ {
alias /home/site/static/;
}
# checks for static file, if not found proxy to app
location / {
try_files $uri #proxy_to_app;
}
location #proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
Latest gunicorn-error.log
/home/site/Site/../bin/gunicorn_start: line 16:
/home/site/Site/../bin/gunicorn_start: Argument list too long
/home/site/Site/../bin/gunicorn_start: line 16: /
/home/site/Site/../bin/gunicorn_start: Success
I don't know why you have such complex setup, here is my account website conf, works like a charm:
[group:accounting]
programs=accounting_web
[program:accounting_web]
command = /home/web/.virtualenvs/accounting/bin/gunicorn accounting.wsgi --workers=1 --threads=4 -b unix:/tmp/gunicorn_accounting.sock --log-level=DEBUG --timeout=120
directory = /home/web/accounting
user = web
environment=PATH="/home/web/.virtualenvs/accounting/bin"
Probably, you have a syntax error on gunicorn_start script. My suggestion is to use a smaller command line directly on supervisor .conf.
On nginx.conf:
1) try to change the Servername parameter with a valid URL, for example:
exactestate.com
2) change the sock configuration to TCP:
upstream gunicorn_panel {
# For a TCP configuration:
server 127.0.0.1:9000 fail_timeout=0; }
server {
listen 8080;
On supervisor.conf, instead of use the gunicorn_start file, try to write all command directly on the command variable:
[program:powerpanel]
command=/home/web/.virtualenvs/accounting/bin/gunicorn powerpanel.wsgi -b 127.0.0.1:9000 -w1 --pythonpath=/home/exactestate/ExactEstate --error-logfile=/home/exactestate/logs/gunicorn-error.log
user=webapp
autostart=true
autorestart=unexpected
startsecs=1
startretries=3
redirect_stderr=true
I have 3 python django application on same server. And I want to run each service using different port.
ex)
80 for end user
8001 for service provider
8002 for service operator
But I have no idea how can I do this.
Now, one uwsgi service is running using systemctl.
This is my uwsgi.service.
# uwsgi.service
[Unit]
Description=uWSGI
After=syslog.target
[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /var/run/uwsgi; chown root:ubuntu
/var/run/uwsgi; chmod g+w /var/run/uwsgi;'
ExecStart=/bin/bash -c 'source /var/www/html/remosys/bin/activate; uwsgi --ini /var/www/html/remosys/uwsgi.ini'
#Restart=always
Restart=on-failure
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
And uwsgi.ini is the following.
[uwsgi]
uid = ubuntu
gid = ubuntu
# Django-related settings
# the base directory (full path)
chdir = /var/www/html/remosys/remoshin
# Django's wsgi file
module = remoshin.wsgi
# the virtualenv (full path)
home = /var/www/html/remosys
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 2
threads = 1
# the socket (use the full path to be safe
socket = /var/run/uwsgi/master.sock
pidfile = /var/run/uwsgi/master.pid
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
thunder-lock = true
max-requests = 6000
max-requests-delta = 300
# log
logto = /var/log/uwsgi/uwsgi.log
deamonize = /var/log/uwsgi/uwsgi-#(exec://date +%Y-%m-%d).log
log-reopen = true
And my nginx setting is the following.
# the upstream component nginx needs to connect to
upstream django {
# for a file socket
server unix:///var/run/uwsgi/master.sock;
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
# substitute your machine's IP address or FQDN
server_name localhost
charset utf-8;
location /clinic {
# your Django project's static files - amend as required
alias /home/ubuntu/public_html/clinic;
}
# max upload size
# Django media
location /static {
# your Django project's static files - amend as required
alias /home/ubuntu/remosys/remoshin/apiv1/static;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
# the uwsgi_params file you installed
include /var/www/html/remosys/uwsgi_params;
}
}
I want to know how can I make settings in order to launch some uwsgi service and how to setting nginx config file.
Would you give me an advice?
Thanks in advance.
uwsgi_p1.ini for my_project1
[uwsgi]
chdir = /root/my_workplace/my_project1
module = my_project1.wsgi
virtualenv = /root/my_workplace/virtual/my_project1
processes = 2
socket = 127.0.0.1:10001 # **pay attention to this port**
vacuum = true
master = true
nginx_p1.conf for my_project1
server {
listen 8888; # use different server_name or listenport
charset utf-8;
client_max_body_size 75M;
server_name project1.mydomain.com; # use different server_name or listenport
location / {
uwsgi_pass 127.0.0.1:10001; # pay attention to here
include uwsgi_params;
}
}
==============================
uwsgi_p2.ini for my_project2
[uwsgi]
chdir = /root/my_workplace/my_project2
module = my_project2.wsgi
virtualenv = /root/my_workplace/virtual/project2
processes = 2
socket = 127.0.0.1:10002
vacuum = true
master = true
nginx_p2.conf for my_project2
server {
listen 8889;
charset utf-8;
client_max_body_size 75M;
server_name project2.mydomain.com;
location / {
uwsgi_pass 127.0.0.1:10002;
include uwsgi_params;
}
}
and so on...
So I want to run django on nginx with uwsgi. I installed everything, changed the ALLOWED_HOSTS and STATIC_ROOT in the settings.py and ran "collectstatic". With the terminal I can see that the admin-static-files were put exactly where I wanted them to be put. Yet I don't see the static files when I go to domainxy.de/admin . After my the installation I did this:
sudo mkdir -p /etc/uwsgi/sites
sudo nano /etc/uwsgi/sites/mysite.ini
with
####mysite.ini####
[uwsgi]
project = mysite
uid = root
base = /%(uid)
chdir = %(base)/%(project)
module = %(project).wsgi:application
master = true
processes = 5
socket = /run/uwsgi/%(project).sock
chown-socket = %(uid):www-data
chmod-socket = 660
vacuum = true
and
sudo nano /etc/systemd/system/uwsgi.service
with
###uwsgi.service####
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown root:www-data /run/uwsgi'
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
and
sudo nano /etc/nginx/sites-available/mysite.conf
with
####mysite.conf####
server {
listen 80;
server_name domainxy.de www.domainxy.de xx.xxx.xxx.xxx;
location = /favicon.ico { access_log off; log_not_found off; }
location /static {
root /root/mysite/;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/mysite.sock;
}
}
and
sudo ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled
sudo systemctl restart nginx
sudo systemctl start uwsgi
sudo ufw allow 'Nginx Full'
Where did I make the mistake? I did change the folders in "mysite.conf" multiple times but nothing helped so far. Thanks for helping. Don't judge me that I am a newbie and also not that I used the root-user for simplifying here.
Edit: my django-project is in /root/mysite/ and the settings.py is
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
I am trying to host multiple sites on VPS using sock file but the problem is that I can't see the website up and running using gunicorn sock. But I can't see my website live. I need to know how do I change the following screen showing my app binds with particular port instead of sock file or if it has to be a sock file then why I can't see it in browser at mydomain.com.
Gunicorn upscript is as follows:
#!/bin/bash
NAME="dressika" # Name of the application
DJANGODIR=/django/mydomain # Django project directory
SOCKFILE=/django/mydomain/run/gunicorn.sock # we will communicte using this unix socket
USER=django # the user to run as
GROUP=django # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=mydomain.settings # which settings file should Django use
DJANGO_WSGI_MODULE=mydomain.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--bind=unix:$SOCKFILE \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--log-file=-
With above settings gunicorn startup script runs fine but I couldn't see my site live on browser or client end. I guess I need to bind it with some port. I am not sure if my assumption is correct. My app settings.py shows in ALLOWED_HOSTS=['mydomain.com', 'www.mydomain.com]. Still the url isn't working.
My Nginx settings are:
upstream mydomain_server {
server 127.0.0.1:9500 fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
root /home/django/mydomain;
index index.html index.htm;
client_max_body_size 4G;
server_name mydomain.com www.mydomain.com;
keepalive_timeout 5;
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2|woff|ttf)$ {
expires 365d;
}
# Your Django project's media files - amend as required
location /media {
alias /home/django/mydomain/media/;
}
# your Django project's static files - amend as required
location static/static-only {
alias /home/django/mydomain/static-only/;
}
# Django static images
location /static/mydomain/images {
alias /home/django/mydomain/static-only/images/;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://mydomain_server;
proxy_connect_timeout 60s;
}
}
I've also tried binding /home/django/mydomain/run/gunicorn.sock with upstream server instead of IP:Port but still couldn't see the site up and running.
I have the same problem, .sock doesn't create. This method helps me.
Prerequests:
Installed nginx: when you type in browser 127.0.0.1 - obtain "Wellcome to nginx...".
You install python2 or 3 no matter, and other stuffs: pip, django, gunicorn...
You installed and settled virtualenv. (in my case, I use virtualenvwrapper - this is good staffs, saves all you env in one folder: /home/user/.virtualenvs/)
You created django project, and when: python manage.py runserver -
you obtain "It works..." - this good news.
When you type gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application - you have the same result, as a step 4.
Next step for setting you dj.project throgh gunicorn to nginx:
You create file in /etc/systemd/system/any_file_name.service - you can named this file as you want, at DO - it names as gunicorn.service.
my method:
$cd /etc/systemd/system
$sudo touch gunicorn.service
and open it your favorite text editor
$sudo subl gunicorn.service
Inside it you write:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=vetal
Group=www-data
WorkingDirectory=/var/www/apple.net
ExecStart=/home/vetal/.virtualenvs/univ/bin/gunicorn --workers 3 --bind unix:/var/www/apple.net/mysite/mysite.sock mysite.wsgi:application
[Install] WantedBy=multi-user.target
ExecStart - what will be started by nginx, when your virualenv will be turned off. Do you remember, gunicorn was install through pip, when your env was turn on ?
-- bind unix:... - this address WHERE your .sock will created! Pay attention for this!
CHECK EVERY LETTER!TWISE!!! (of course with you links..)
Type:
$ls -l
if you see in attributes to your 'gunicorn.service' something:
-rw-r--r-- 1 root root 0 Янв 12 11:48 gunicorn.service
this means - this file is not executable, and you .sock - file will never created! Make next:
$sudo chmod 755 gunicorn.service
and check:
$ls -l
if you get:
-rwxr-xr-x 1 root root 305 Янв 11 19:48 gunicorn.service
this good! Everything allright!
Then you created nginx block, in /etc/nginx/site-available/ it likes next:
server {
listen 80;
root /var/www/apple.net;
server_name apple.net;
location = /favicon.ico { access_log off; log_not_found off; }
location = /static/ {
alias /var/www/apple.net/static/;
}
location / {
include proxy_params;
proxy_pass http://unix:/var/www/apple.net/mysite/mysite.sock;
} }
Notice: proxy_pass - must be identicaly correct with folder where .sock file created in gunicorn.service!
Copies this file to /sites-enable
$ sudo cp /etc/nginx/site-avaliable/apple.net /etc/nginx/site-enable
I don't have any domaine, so I modify my /etc/hosts file, add row:
127.0.0.10 apple.net
Very important steps!!!
$pkill gunicorn - this step kill daemon, which you may started before. gunicorn in this case, means name of file which you created before with .service extention, in /etc/systemd/system - folder.
Start gunicorn.service daemon:
$sudo systemctl start gunicorn
$sudo systemctl enable gunicorn
Start(or restart nginx)
$sudo /etc/init.d/nginx (re)start
Check your domane name in browser.
Since gunicorn is running on a socket, you need to bind to that socket, not to a port, in the upstream section.
upstream mydomain_server {
server unix:/home/django/mydomain/run/gunicorn.sock fail_timeout=0;
}
I have nginx serving up a .sock file from gunicorn. My typical gunicorn call looks like this:
exec gunicorn \
--pid /web/gunicorn.pid \
--workers '4' \
--name myapp \
--chdir /src/myapp \
--bind unix:/web/.sock \
--log-file=- \
myapp.wsgi:application
My nginx conf for / looks like this; the main difference seems to be that your proxy_pass statement doesn't point to the .sock file:
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/web/.sock;
}
-I'm using a virtual machine with Ubuntu 12.04.3 LTS
-I'm doing a Django project with Uwsgi + nginx
-I added "192.168.33.50 myproject.com" to my hosts file
-I started uwsgi + supervisor + nginx process
-When I'm trying to access to myproject.com, I'm getting this error in /var/log/nginx/error.log:
2013/11/13 07:43:21 [crit] 14741#0: *1 connect() to
unix:/tmp/uwsgi_myproject.sock failed (2: No such file or
directory) while connecting to upstream, client: 192.168.33.1, s$
Edition 1
This is my uwsgi.ini:
[uwsgi]
module = myproject.wsgi:application
master workers = 3
logto = /vagrant/log/uwsgi.log
socket = /tmp/uwsgi_myproject.sock
pidfile = /tmp/uwsgi_myproject.pid chmod-socket = 666
auto-procname need-app vacuum
Edition 2
If I execute this command in console:
uwsgi --ini /vagrant/uwsgi.ini --chdir /vagrant/myproject/ --socket
/tmp/uwsgi_myproject.sock --pidfile /tmp/myproject.pid
With that command, uwsgi starts and I can access to myproject.com but it's supossed that uwsgi starts with supervisor of django
Edition 3
This is myproject.conf in /etc/nginx/conf.d/
server {
listen 80;
charset utf-8;
sendfile off;
# ONIX files
client_max_body_size 100M;
location /media/imagen {
include uwsgi_params;
#The uwsgi_pass must comply with the details in supervisord.conf
uwsgi_pass unix:/tmp/uwsgi_myproject.sock;
}
location /media/resources/protected {
root /vagrant/myproject/myproject;
internal;
}
location /media {
root /vagrant/myproject/myproject;
}
location /static {
root /vagrant/myproject/myproject;
}
location / {
include uwsgi_params;
#The uwsgi_pass must comply with the details in supervisord.conf
uwsgi_pass unix:/tmp/uwsgi_myproject.sock;
uwsgi_read_timeout 300;
}
}
EDITED: ADDED SUPERVISOR.CONF ASKED BY #ChrisC
[supervisord]
logfile={{ PROJECT_DIR }}/../log/supervisord.log
pidfile=/tmp/supervisor_PROJECTNAME.pid
user=PROJECTNAME
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8,LC_LANG=en_US.UTF-8
[unix_http_server]
file = /tmp/supervisor_PROJECTNAME.sock
[program:__defaults__]
directory={{ PROJECT_DIR }}
startsecs=5
[program:autoreload]
exclude=true
[program:uwsgi]
command=uwsgi --ini {{ PROJECT_DIR }}/../uwsgi.ini --chdir {{ PROJECT_DIR }} --socket /tmp/uwsgi_PROJECTNAME.sock --pidfile /tmp/uwsgi_PROJECTNAME.pid
stopsignal=INT
The problem was in the configuration of the supervisor. The supervisor wasn't loading the uwsgi process well.