Operations 5 min read

Introduction to Supervisor Process Management Tool and Installation Guide

This article introduces Supervisor, a Python‑based Linux process manager, explains the issues caused by not using a daemon, and provides step‑by‑step instructions for installing, configuring, and enabling Supervisor with example configuration and common control commands.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Introduction to Supervisor Process Management Tool and Installation Guide

Supervisor is a Python‑developed client/server daemon for Linux/Unix that provides process management capabilities such as monitoring, starting, stopping, and restarting one or multiple processes, automatically relaunching them if they unexpectedly terminate; it does not support Windows.

Without a daemon, three problems may occur: (1) PHP applications run inside a shell and are terminated when the shell closes, causing service outage; (2) If a PHP process crashes, manual shell intervention is required to restart it, often not timely; (3) After a server crash or reboot, processes must be manually started again.

To solve these issues, a program is needed to monitor PHP applications and immediately restart them when they stop.

Installation and configuration steps:

1. Install the Python package manager:

yum install python-setuptools

2. Install Supervisor:

easy_install supervisor

3. Create the Supervisor configuration directory and generate the default configuration file:

mkdir /etc/supervisor
echo_supervisord_conf > /etc/supervisor/supervisord.conf

Append the following to the end of supervisord.conf to include additional configuration files:

;[include]
;files = relative/directory/*.ini

;conf.d is the directory for configuration files and must be created manually
[include]
files = conf.d/*.conf

4. Create a program‑specific .conf file under /etc/supervisor/conf.d/ . Example for a .NET service named MGToastServer :

[program:MGToastServer] ; program name
command=dotnet MGToastServer.dll ; command to run the program
directory=/root/文档/toastServer/ ; working directory
autorestart=true ; restart automatically if it exits unexpectedly
stderr_logfile=/var/log/MGToastServer.err.log ; error log file
stdout_logfile=/var/log/MGToastServer.out.log ; output log file
environment=ASPNETCORE_ENVIRONMENT=Production ; environment variables
user=root ; user to run the program
stopsignal=INT

5. Start Supervisor and verify that the program is running:

supervisord -c /etc/supervisor/supervisord.conf
ps -ef | grep MGToastServer

6. Configure Supervisor to start on boot by creating a systemd service file supervisord.service :

# dservice for systemd (CentOS 7.0+)
# by ET‑CS (https://github.com/ET‑CS)
[Unit]
Description=Supervisor daemon

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42

[Install]
WantedBy=multi-user.target

Copy the file to /usr/lib/systemd/system/supervisord.service , enable it, and verify:

systemctl enable supervisord
systemctl is-enabled supervisord

7. Common Supervisor control commands:

supervisorctl restart
; restart a specific app
supervisorctl stop
; stop a specific app
supervisorctl start
; start a specific app
supervisorctl restart all                  ; restart all apps
supervisorctl stop all                     ; stop all apps
supervisorctl start all                    ; start all apps
OperationsconfigurationProcess ManagementLinuxInstallationSupervisorsystemd
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.