The supervisord is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.
It shares some of the same goals of programs like launchd, daemontools, and runit. Unlike some of these programs, it is not meant to be run as a substitute for init as “process id 1”. Instead, it is meant to be used to control processes related to a project or a customer, and is meant to start like any other program at boot time. here we see how to install supervisord with systemd
The problem!
when installing supervisord with pip, it runs like a python program. but when the server reboots, it’s needed to start again. this is a major problem.
here we are going to see how to install supervisord with systemd from pip.
first of all lets install pip
$ sudo apt install python3-dev $ sudo apt install python3-pip
Pip is instelled, install supervisor by following commad:
$ pip3 install supervisor
create custom config directory:
$ mkdir -p /etc/supervisor/conf.d/
Even the supervisor in installed from the pip, but it has no config file. so we have to paste the default config file to our custom config dir:
$ echo_supervisord_conf > /etc/supervisor/supervisord.conf
add these lines at the bottom of /etc/supervisor/supervisord.conf to read the configs from our custom dir:
[include] files=/etc/supervisor/conf.d/*.conf
the final step : adding supervisord as system service for preventing reboot failures
create a file named /etc/systemd/system/supervisord.service and add the following lines:
[Unit] Description=Supervisor daemon Documentation=http://supervisord.org After=network.target [Service] ExecStart=/usr/local/bin/supervisord -n -c /etc/supervisor/supervisord.conf ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target Alias=supervisord.service
verify and restart supervisor by,
$ sudo systemctl enable supervisord.service $ sudo systemctl start supervisord.service
this is helpful for all Linux systems.