Supervisor installation - Schibsted-Tech-Polska/sfi-message-brokering GitHub Wiki
Supervisor installation
-
- Install supervisor package
sudo apt-get install supervisor
-
- Adding workers
New programs are given to Supervisor through configuration files
The program configuration files for Supervisor programs are found in the /etc/supervisor/conf.d directory, normally with one program per file and a .conf extension. A simple configuration for our script, saved at /etc/supervisor/conf.d/long_script.conf, would look like so:
[program:worker]
command=(path to php interpretter e.g: /usr/local/bin/php) (path to your script)
autostart=true
autorestart=true
stderr_logfile=/var/log/long.err.log
stdout_logfile=/var/log/long.out.log
Once the configuration file is created, let's inform Supervisor about new configuration by typing:
sudo supervisorctl reread
Followed by telling it to make any changes with:
supervisorctl update
We can check if worker is running by looking at the output log file defined in worker configuration:
tail -f /var/log/long.out.log
To enter the interactive mode, start supervisorctl with no arguments
To start in a simple manner, we can start, stop and restart a program with the associated commands followed by the program name:
supervisor> stop worker
worker: stopped
supervisor> start worker
worker: started
supervisor> restart worker
worker: stopped
worker: started
Enabling GUI
Add below configuration to supervisord's global configuration file in /etc/supervisor/supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9002 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
Once the configuration file is updated run:
sudo supervisorctl reread
Go to http://127.0.0.1:9002 and log into supervisor status panel