supervisor进程管理
安装
apt-get install python3-pip
apt-get install supervisor
supervisord -h
配置文件
主服务启动文件
/etc/supervisor/supervisord.conf
需要读取的进程文件
/etc/supervisor/conf.d/*.conf
写了一个go-fastdfs服务的文件展示
- Log文件夹需要提前创建
- /etc/supervisor/conf.d/go_fastdfs_server.conf文件
[program:go_fastdfs_server]
directory=/root/go-fastdfs/
command=/root/go-fastdfs/fileserver server
stdout_logfile=/etc/supervisor/log/go_fastdfs_server.log
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true
- /etc/supervisor/conf.d/goFastDfsServer.conf文件(注意点:stopasgroup设置为false就是主进程关闭是否也关闭子进程)
[program:go_fastdfs_web_go]
directory=/root/go-fastdfs-web-go
command=/root/go-fastdfs-web-go/go-fastdfs-web-go
stdout_logfile=/etc/supervisor/log/go_fastdfs_web.log
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=flase
killasgroup=flase
启动
- 直接启动服务, 里面会自动扫描conf.d目录下的所有服务来启动
supervisord -c /etc/supervisor/supervisord.conf
检查
# 查看正在运行的进程
supervisorctl status
# 重新加载进程
supervisorctl update
# 重启某个进程
supervisorctl restart xxxxx