Operations 10 min read

How to Install and Configure Supervisor on CentOS 7 for Process Management

This guide walks through installing Supervisor on CentOS 7, configuring its core settings, creating program definitions for Tomcat and Redis, and managing services with supervisord and supervisorctl, providing a reliable solution for automatic process recovery on Linux/Unix systems.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Install and Configure Supervisor on CentOS 7 for Process Management

Supervisor is a Python‑based client/server daemon for process management on Linux/Unix (no Windows support). It monitors, starts, stops, and restarts processes, automatically relaunching any that exit unexpectedly, eliminating the need for custom shell scripts.

Prerequisites and Environment

Ensure Python 2.4+ is installed. The example uses CentOS 7.6 with Python 2.7.5. Verify the OS version with cat /etc/redhat-release and Python version with python -V. If Python is below 2.6, upgrade (example shows installing Python 3.6.8 from source).

Installing Supervisor

Three installation methods are presented; the guide uses the easy_install approach:

Install setuptools:

wget https://pypi.io/packages/source/s/setuptools/setuptools-33.1.1.zip
unzip setuptools-33.1.1.zip
cd setuptools-33.1.1
python setup.py install

Install Supervisor via easy_install supervisor.

Alternative methods (pip and yum) are also listed for reference.

Supervisor Executables

After installation, three binaries are available: supervisord – the daemon managing services. supervisorctl – client for issuing control commands. echo_supervisord_conf – generates a default configuration file.

Generating and Editing Configuration

Run echo_supervisord_conf > /etc/supervisord.conf (skip if using yum). Create /etc/supervisord.d for individual program configs. Modify the main config to change the socket file mode and include the /etc/supervisord.d/*.conf directory:

sed -i 's/;chmod=0700/chmod=0766/g' /etc/supervisord.conf
sed -i '$a [include]
files = /etc/supervisord.d/*.conf' /etc/supervisord.conf

Example: Managing Tomcat

Install Tomcat and Java, then create /etc/supervisord.d/tomcat.conf with:

[program:tomcat]
directory=/usr/local/tomcat
command=/usr/local/tomcat/bin/catalina.sh run
autostart=true
startsecs=10
autorestart=true
startretries=3
user=root
priority=999
stopsignal=INT
redirect_stderr=true
stdout_logfile_maxbytes=200MB
stdout_logfile_backups=100
stdout_logfile=/usr/local/tomcat/logs/catalina.out
stopasgroup=false
killasgroup=false

Start the daemon with supervisord -c /etc/supervisord.conf. Tomcat will launch automatically due to autostart=true. Use supervisorctl status/start/stop/restart tomcat to manage it.

Example: Managing Redis

Redis runs in the foreground when daemonize no, making it suitable for Supervisor. Sample Redis config ( redis6001.conf) is provided. Create /etc/supervisord.d/redis.conf:

[program:redis]
 directory=/usr/local/redis
 command=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis6001.conf
 autostart=true
 startsecs=10
 autorestart=true
 startretries=3
 user=root
 priority=999
 stopsignal=INT
 redirect_stderr=true
 stdout_logfile_maxbytes=200MB
 stdout_logfile_backups=100
 stdout_logfile=/usr/local/redis/logs/redis6001.log
 stopasgroup=false
 killasgroup=false

Control Redis with supervisorctl status/start/stop/restart redis.

Systemd Integration

Create /usr/lib/systemd/system/supervisord.service:

[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service nss-user-lookup.target

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf

[Install]
WantedBy=multi-user.target

Enable and start the service with systemctl enable supervisord and systemctl start supervisord.

Managing All Programs

Supervisor can list or control all configured programs:

supervisorctl status all
supervisorctl stop all
supervisorctl start all
supervisorctl restart all
supervisorctl reload all

This comprehensive setup provides reliable, automatic recovery for critical services like Tomcat and Redis on Linux servers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

redisprocess managementTomcatCentOSSupervisor
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

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.