Operations 9 min read

Master Supervisor on CentOS: Install, Configure, and Manage Tomcat & Redis

This guide walks you through installing Supervisor on CentOS 7.6, configuring its core settings, creating process definitions for Tomcat and Redis, and using supervisorctl and systemd to start, stop, and monitor these services, ensuring automatic recovery on failure.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Supervisor on CentOS: Install, Configure, and Manage Tomcat & Redis

Experimental Environment

System platform : CentOS Linux release 7.6.1810 (Core)

Python version : Python 2.7.5

Install Supervisor

Three installation methods are presented; the article uses the third (yum epel‑release). The commands are:

yum install -y epel-release && yum install -y supervisor

Other methods:

# easy_install
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
easy_install supervisor
# pip
pip install supervisor

Supervisor Commands

After installation three executables are available: supervisord: the daemon managing Supervisor itself supervisorctl: client to control managed processes echo_supervisord_conf: generates a default configuration file

Generate and Edit Configuration

Generate the initial config file:

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

Modify the socket mode and include additional config files:

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

Manage Tomcat with Supervisor

Install Tomcat and create a program section in /etc/supervisord.d/tomcat.conf:

[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 Tomcat via Supervisor:

supervisord -c /etc/supervisord.conf   # autostart launches Tomcat

Manage Redis with Supervisor

Redis runs in foreground (no daemonize yes) and can be managed similarly. 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

Process Management with supervisorctl

Common commands:

supervisorctl status all          # view all processes
supervisorctl start tomcat        # start Tomcat
supervisorctl stop redis          # stop Redis
supervisorctl restart tomcat      # restart Tomcat
supervisorctl reload              # reload configuration

Systemd Service for supervisord

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 verify:

systemctl enable supervisord
systemctl is-enabled supervisord
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 managementSystem AdministrationCentOSSupervisor
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.