Centos, Ubuntu deploy Supervisor

Supervisor deployment

Centos7 installation

# yum install epel-release

# yum -y install supervisor

# systemctl enable supervisord



# systemctl start supervisord # 启动supervisord服务 

# systemctl status supervisord # 查看supervisord服务状态 

# ps -ef|grep supervisord # 查看是否存在supervisord进程

## 修改配置文件 到文件最后一行修改

vim /etc/supervisord.conf

[include]
files = supervisord.d/*.conf

# systemctl restart supervisord 

Ubuntu cheap

# apt-get install supervisor

vim /etc/supervisor/supervisord.conf 

[include]
files = /etc/supervisor/conf.d/*.conf

# systemctl enable supervisor
# systemctl start supervisor

Generate a process management file under the configuration file

vim /etc/supervisord.d/task.conf # ubuntu /etc/supervisor/conf.d/task.conf

[program:task]                                       #管理进程的命名
directory=/root/test                    #命令执行的工作空间
command=python test.py  -c test.conf          #执行的命令
user=root                          #指定用户
stderr_logfile=/var/log/supervisor/test.log      #错误日志输出路径
stdout_logfile=/var/log/supervisor/test.log      #日志输出路径
autostart=true                       #自动启动
autorestart=true                      #自动重启</pre>

supervisorctl Commonly used commands:

command Description
supervisorctl stop program_name Stop a process
supervisorctl start program_name Start a process
supervisorctl restart program_name Restart a process
supervisorctl stop all Stop all processes
supervisorctl reload Load the latest configuration file, stop the original process and start and manage all processes according to the new configuration
supervisorctl update According to the latest configuration file, start a new configuration or a process with a change, and the process without a configuration change will not be affected and restart
supervisorctl status View the current process status

Nginx process management configuration file

cat /etc/supervisord.d/nginx.conf 
[program:nginx]
directory=/data/nginx
command=/data/nginx/sbin/nginx -g 'daemon off;'
autorestart=true
autostart=true
user=root
stopasgroup=true
killasgroup=true
stderr_logfile=/data/nginx/logs/nginx_err.log
stdout_logfile=/data/nginx/logs/nginx.log

Mysql process management configuration file

cat /etc/supervisord.d/mysql.conf 
[program:mysql]
command=/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/3306/my.cnf --user=mysql
autorestart=true
autostart=true
startretries=3
user=mysql
startsecs=10
stopwaitsecs=50
priority=3

redirect_stderr=true
stdout_logfile_maxbytes = 1024MB
stdout_logfile_backups  = 10
stdout_logfile=/data/mysql/3306/logs/mysql.log

Yearning process management configuration file

cat /etc/supervisord.d/yearning.conf 
[program:yearning]
directory=/data/Yearning
command=/data/Yearning/Yearning -s -b "10.10.xxx.xxx" -p "8000"
autorestart=true
autostart=true
user=root
stopasgroup=true
killasgroup=true
stderr_logfile=/data/Yearning/logs/yearning_err.log
stdout_logfile=/data/Yearning/logs/yearning.log

 

Guess you like

Origin blog.csdn.net/ganices/article/details/110915425