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.
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 supervisorOther 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 supervisorSupervisor 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.confModify 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.confManage 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=falseStart Tomcat via Supervisor:
supervisord -c /etc/supervisord.conf # autostart launches TomcatManage 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=falseProcess 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 configurationSystemd 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.targetEnable and verify:
systemctl enable supervisord
systemctl is-enabled supervisordSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
