Supervisor

Running processes in supervisor

Supervisor is a process manager which greatly simplifies the management of long running programs by providing a simple and straightforward interface. Supervisor consists of a server part called supervisord, which creates and manages all the processes, and a supervisorctl system/web interface to manage and monitor supervisord.

Installation.

On Debian/Ubuntu you can install from the repository:

apt-get install supervisor

After installing, supervisor needs to be configured and the programs/processes it will manage need to be added The configuration file is located in /etc/supervisor/supervisord.conf (for Ubuntu, Debian) or **/etc/supervisord.conf ** for other systems.

To add a new process (vorker) you need to add the same code to the file:

[program:worker]
command=/usr/bin/php /var/www/worker.php
stdout_logfile=/var/log/worker.log
autostart=true
autorestart=true
user=www-data
stopsignal=KILL
numprocs=1

Parameters:

  • [program:worker] - the name of the process/worker to which all the following parameters of the section will refer;
  • command=/usr/bin/php /var/www/worker.php - path to program's executable file;
  • stdout_logfile=/var/log/worker.log - console output to a file;
  • autostart=true - start vorker together with supervisor;
  • autorestart=true - to restart the worker if it crashed for some reason;
  • user=www-data - to start the process under a certain user;
  • stopsignal=KILL - stops the process;
  • numprocs=1 - number of instances of the specified worker.

After adding new processes/workers it is necessary to restart supervisor:

/etc/init.d/supervisor restart

Supervisor gives the possibility to enable the supervisorctl web user interface which is enabled by means of a configuration file. To do this, you have to change the section [inet_http_server] by entering the correct username and password:

[inet_http_server]
port=127.0.0.1:9001
;username=some_user_name
;password=some_password

Additional features: Supervisor has a built-in event monitoring mechanism with which the system can notify about errors:

[eventlistener:memmon]
command=memmon -a 200MB -m [email protected]
events=TICK_60
Need help?Our engineers will help you free of charge with any question in minutesContact us