Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.
-- Supervisor: A Process Control System — Supervisor 4.2.5 documentation
- HTTP server to monitor your services. It can be enabled by specifying the [inet_http_server] setting inside
/etc/supervisor/supervisord.conf
. It shouldn't be exposed on the internet though. - Easy to set up log rotation. It can also be configured with Logrotate.
- needs additional installation, in contrast to Systemd, that comes pre-installed on most linux distributions
- can not bind to privileged ports, smaller than 1024
$ sudo apt-get -y install supervisor
$ sudo systemctl enable supervisor
$ sudo systemctl start supervisor
- Place your Django application under
/srv
[^srv] inside a directory calledmy_awesome_project
. - Create your virtual environment inside the same directory in a directory called
.venv
. - Now you can create a new file inside
/etc/supervisor/conf.d/
calledmy_awesome_project.conf
:
[program:my_awesome_project]
directory=/srv/%(program_name)s
command=/srv/%(program_name)s/run
environment=/srv/%(program_name)s/.venv
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
After you saved the file, you need to tell Supervisor to reload the configuration:
$ sudo supervisorctl reread
$ sudo supervisorctl update