pip install supervisor
sudo apt-get install supervisor
Add your project configuration file in the directory supervisor use at startup
Supposing you have a gunicorn conf file already written gunicorn.conf.py, like this for example:
bind = "0.0.0.0:8001" logfile = "/home/user/app/gunicorn.log" workers = 3
write your supervisor file configuration:
sudo vi /etc/supervisor/conf.d/mysite.conf
command=/home/user/.virtualenvs/ENV/bin/gunicorn_django -c /home/user/app/gunicorn.conf.py directory=/home/user/app/ user=user autostart=true autorestart=true priority=991 stopsignal=KILL
If you get a UnicodeEncodeError
Add this environment line
in the [supervisord] section of
to avoid this error
django set 'LC_ALL' to a correct value, eg: 'en_US.UTF-8'.
If you’re taking advantage of the internationalization features of Django (see Internationalization and localization) and you intend to allow users to upload files, you must ensure that the environment used to start Apache is configured to accept non-ASCII file names. If your environment is not correctly configured, you will trigger UnicodeEncodeError exceptions when calling functions like os.path() on filenames that contain non-ASCII characters.
To avoid these problems, the environment used to start Apache should contain settings analogous to the following:
export LANG='en_US.UTF-8' export LC_ALL='en_US.UTF-8'
Consult the documentation for your operating system for the appropriate syntax and location to put these configuration items; /etc/apache2/envvars is a common location on Unix platforms. Once you have added these statements to your environment, restart Apache.
sudo /etc/inid.d/apache2 restart sudo /etc/init.d/supervisor stop sudo /etc/init.d/supervisor start
to test your configuration
sudo supervisorctl update
this could be enough, to stop your app
sudo supervisorctl stop mysite
to start it manually again
sudo supervisorctl start