supervisor, C/S架构的进程控制系统,可使用户在类UNIX系统中监控、管理进程。常用于管理与某个用户或项目相关的进程。
设计理念
方便,精确,托管,进程分组
特点
使用简单,中心化管理,高效,可扩展,兼容所有类UNIX系统,久经考验
Supervisor组件
supervisord服务器端,配置文件通常放置于/etc/supervisord.conf
supervisorctl命令行客户端
Web Server 通过浏览器操作的客户端
XML-RPC Interface扩展接口
实际操作命令
安装
pip install supervisor
生成配置文件模版
echo_supervisord_conf > supervisord.conf
配置程序
在supervisord.conf文件末尾
;====================================celery-worker====================================
[program:celery-worker]
command=/home/ec2-user/workspace/ENV3/bin/celery -A tasks worker -l INFO
directory=/home/ec2-user/workspace/backend/src
process_name="celery-worker-%(process_num)s"
numprocs=2
autostart=true
user=ec2-user
stdout_logfile=/home/ec2-user/logs/celery.log
stderr_logfile=/home/ec2-user/logs/celery.log
autostart=true
autorestart=true
将配置文件复制到/etc目录
sudo cp supervisord.conf /etc/
启动(指定配置文件)
supervisord -c /etc/supervisord.conf
查看进程运行状态
supervisorctl status
启动或停止服务
supervisorctl stop|start program_name
supervisorctl stop|start all #停止|启动所有程序
重启程序
supervisorctl restart program_name
supervisorctl restart all #重启所有程序
更新配置并运行
supervisorctl update
停止supervisord服务器并关闭所有托管程序
supervisorctl shutdown
这个命令之后只能使用启动命令重新启动服务








网友评论