Supervisor: A Process Control System

For these days I had the possibility to work with a great tool in my job. This tool allows us to monitor and control a number of processes on Unix operating systems.

As their website says: “Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.“.

Supervisor is written in Python and based on a configuration file (supervisord.conf) the daemon (supervisord) keeps monitoring for defined processes are running, and if the process is killed by whatever cause the supervisord start it again.

A configuration file looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[supervisord]
logfile=/var/log/supervisord.log

[unix_http_server]
file=/tmp/supervisor.sock
username=supervisor
password=mysecret

[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

[inet_http_server]
port=*:5858
username=supervisor
password=mysecret

// Programs
[program:email_sender]
command=/usr/bin/php email_sender.php --arg1=a --arg2=b
user=www-data
autorestart=true
stderr_logfile=/var/log/email_sender_%(process_num)1d.err.log
stdout_logfile=/var/log/email_sender_%(process_num)1d.out.log
numprocs=2
process_name=%(program_name)s_%(process_num)02d

And a web app shows us a status of processes:

supervisor-screenshot

For more information you can read the documentation.