supervisor 使用教程python守护进程
=======================================================
1.安装
pip3 install supervisor -i https://pypi.tuna.tsinghua.edu.cn/simple 2.使用supervisor 启动 python main.py 文件
vim /etc/supervisor/conf.d/demo.conf添加以下内容:
==============================
[program:demo] command=python main.py stderr_logfile=/var/log/supervisor/error_demo.log stdout_logfile=/var/log/supervisor/demo.log directory=/root/demo/ autostart=true user=root autorestart=true
==============================
更新配置:
supervisorctl update
=================
PS:如果失败:
error: <class 'xmlrpc.client.Fault'>
请需要先关闭supervisor进程
由于当前进程启动需要关闭,重新开始。
ps -ef | grep supervisord
kill -s SIGTERM 981
supervisord -c /etc/supervisord.conf
=================
查看进程运行状态
supervisorctl status 停止supervisor服务
service supervisor stop 启动supervisor服务
service supervisor start 关闭所有任务
supervisorctl shutdown启动或停止服务
supervisorctl stop|start program_name查看所有任务状态
supervisorctl status更新配置并运行
supervisorctl update参考地址:https://www.jianshu.com/p/94444349d33b