Python进程管理|Python进程管理 supervisor常用命令
yum install python-setuptools
pip install supervisor
测试安装是否成功:
#echo_supervisord_conf
创建supervisor配置文件目录/etc/supervisor/
#mkdir -m 755 -p /etc/supervisor/
创建主配文件supervisord.conf
#echo_supervisord_conf > /etc/supervisor/supervisord.conf
在主配文档中加入执行的程序
vi /etc/supervisor/supervisord.conf (加入命令行)
[program:index]
command=python /www/wwwroot/api5.menglechong.net/index.py
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile=/root/zyk.log
[program:replay]
command=python /www/wwwroot/api5.menglechong.net/replay.py
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile=/root/replay.log[include]
files = /etc/supervisor/conf.d/*.ini
启动supervisor
# supervisord -c /etc/supervisor/supervisord.conf
或
supervisorctl
supervisorctl -c /etc/supervisor/supervisord.conf
每次修改配置文件后需进入supervisorctl,执行reload
设置开机自动启动
1>、进入/lib/systemd/system目录,并创建supervisor.service文件
[Unit]
Description=supervisor
After=network.target[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s[Install]
WantedBy=multi-user.target
2、 设置开机启动
systemctl enable supervisor.service
systemctl daemon-reload
【Python进程管理|Python进程管理 supervisor常用命令】3、修改文件权限为766
chmod 766 supervisor.service
推荐阅读
- 基于微信小程序带后端ssm接口小区物业管理平台设计
- 2020-04-07vue中Axios的封装和API接口的管理
- python学习之|python学习之 实现QQ自动发送消息
- 逻辑回归的理解与python示例
- python自定义封装带颜色的logging模块
- 【Leetcode/Python】001-Two|【Leetcode/Python】001-Two Sum
- Python基础|Python基础 - 练习1
- 全过程工程咨询——时间管理(12)
- Python爬虫|Python爬虫 --- 1.4 正则表达式(re库)
- 《卓有成效的管理者》第二十二堂课(创造英雄)