Centos,Ubuntu部署Supervisor

Supervisor部署

Centos7 安装

# 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 安装

# apt-get install supervisor

vim /etc/supervisor/supervisord.conf 

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

# systemctl enable supervisor
# systemctl start supervisor

在配置文件下生成进程管理文件

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 常用命令:

命令 说明
supervisorctl stop program_name 停止某个进程
supervisorctl start program_name 启动某个进程
supervisorctl restart program_name 重启某个进程
supervisorctl stop all 停止全部进程
supervisorctl reload 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程
supervisorctl update 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
supervisorctl status 查看当前的进程状态

Nginx进程管理配置文件

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进程管理配置文件

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进程管理配置文件

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

猜你喜欢

转载自blog.csdn.net/ganices/article/details/110915425