1、直接上案例
1、安装
pip install supervisor
2、生成supervisor的配置文件
echo_supervisord_conf > /etc/supervisord.conf
3、创建被管理脚本的配置文件
创建supervisord.d文件夹,以后我们所有的脚本配置文件都写到这个文件夹下
/etc/supervisord.d/spider_manager.conf
最精简的配置文件内容
[program:spider_manager] # 指定下名字
command=python3 -u /bots/manager.py # 启动命令
autorstart=true # 是否开启自启
autorestart=true # 是否自动重启
4、把我们的脚本配置文件include进supervisor配置文件
打开第二步生产的/etc/supervisord.conf文件,找到include,修改为代码所示。意思为把/etc/supervisord.d下面的所有的.conf文件都导入进来
[include]
files = /etc/supervisord.d/*.conf
5、更新加载
更新加载新的配置文件
supervisorctl pudate
supervisord 启动服务
6、常用命令
$ supervisorctl status
$ supervisorctl stop usercenter
$ supervisorctl start usercenter
$ supervisorctl restart usercenter
$ supervisorctl reread
$ supervisorctl update
https://cikeblog.com/supervisor.html
本文介绍了如何使用Supervisor管理Python脚本,包括安装Supervisor、创建配置文件、设置自动启动和重启选项,以及通过命令行工具进行控制。通过在/etc/supervisord.d目录下管理脚本配置,并更新加载配置,可以便捷地监控和管理后台进程。
214

被折叠的 条评论
为什么被折叠?



