1、安装sudo apt-get install supervisor
2、查看版本supervisord -v
3、cd /etc/supervisor/conf.d
4、sudo vim main.conf
实例
[program:main]
environment=PYTHONPATH='/home/nvidia/.local/lib/python3.6/site-packages/' #解决module找不到
directory=/home/nvidia/lf/main
command=/usr/bin/python3 -u main.py #-u解决python print无法打印
stopasgroup=true
autostart=true #自启动
user=root #启动用户
# 查看进程状态 #
supervisorctl status
# 启动,停止,重启 所有进程 #
supervisorctl start all
supervisorctl stop all
supervisorctl restart all
# 启动某个进程(program_name=你配置中写的程序名称) #
supervisorctl start program_name
# 多进程重启 #
# 缺点:多个进程需要多次启动,这种比较平滑,可以写个 shell 去循环 restart #
supervisorctl restart program_name:program_name_0
supervisorctl restart program_name:program_name_1
# 这种通配符会同时重启所有进程,先 stop 所有,再 start 所有,不够平滑 #
supervisorctl restart program_name:*
# 更新配置,平滑启动 适用于:修改配置或新增配置 #
supervisorctl reread
supervisorctl update
# 重启所有进程 #
supervisorctl reload