Publish: 2017-08-13 | Modify: 2018-09-28
supervisord is a process management tool for Linux/Unix systems.
yum install supervisor
systemctl enable supervisord.service
The configuration file for supervisord is located at /etc/supervisord.conf
. Custom configuration files with .ini
extension can be placed in the directory /etc/supervisord.d
.
Start:
systemctl start supervisord.service
Stop:
systemctl stop supervisord.service
Restart:
systemctl restart supervisord.service
For example, to configure an nginx process, create a file /etc/supervisord.d/nginx.ini
with the following content:
[program:nginx]
command = /www/lanmps/bin/nginx start
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = www
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /www/logs/usercenter_stdout.log
stopasgroup = false
killasgroup = false
Check status:
supervisorctl status
Stop nginx:
supervisorctl stop nginx
Start nginx:
supervisorctl start nginx
Restart nginx:
supervisorctl restart nginx
Reread the configuration:
supervisorctl reread
Update with new configuration:
supervisorctl update
The configuration file /etc/supervisord.conf
contains the following sections:
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[program:xx]
command=/opt/apache-tomcat-8.0.35/bin/catalina.sh run
autostart=true
startsecs=10
autorestart=true
startretries=3
user=tomcat
priority=999
redirect_stderr=true
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=20
stdout_logfile=/opt/apache-tomcat-8.0.35/logs/catalina.out
[include]
files=/etc/supervisord.d/*.ini
References:
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.