Using Supervisor to start Gunicorn
Install Supervisor.
jitsejan@jjsvps:~$ sudo pip install supervisor
Create the default configuration file for Supervisor.
jitsejan@jjsvps:~$ sudo echo_supervisord_conf > /etc/supervisord.conf
Create the configuration file for the website.
jitsejan@jjsvps:~$ sudo nano /etc/supervisor/conf.d/website.conf
Enter the following.
; /etc/supervisor/conf.d/website.conf
[program:website]
command=gunicorn -c /opt/env/gunicorn_config.py django_project.wsgi:application
directory=/opt/env/django_project/
user=jitsejan
autostart=True
autorestart=True
redirect_stderr=True
Make the file executable.
jitsejan@jjsvps:~$ sudo chmod a+x /etc/supervisor/conf.d/website.conf
Reload Supervisor to find the new file and update the configuration.
jitsejan@jjsvps:~$ sudo supervisorctl reread
jitsejan@jjsvps:~$ sudo supervisorctl update
Now you can start the website with the following command.
jitsejan@jjsvps:~$ sudo supervisorctl start website