1卵酪、安裝sudo apt-get install supervisor
2、查看版本supervisord -v
3谤碳、cd /etc/supervisor/conf.d
4溃卡、sudo vim main.conf
實(shí)例
[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 #自啟動(dòng)
user=root #啟動(dòng)用戶
# 查看進(jìn)程狀態(tài) #
supervisorctl status
# 啟動(dòng),停止估蹄,重啟 所有進(jìn)程 #
supervisorctl start all
supervisorctl stop all
supervisorctl restart all
# 啟動(dòng)某個(gè)進(jìn)程(program_name=你配置中寫的程序名稱) #
supervisorctl start program_name
# 多進(jìn)程重啟 #
# 缺點(diǎn):多個(gè)進(jìn)程需要多次啟動(dòng)塑煎,這種比較平滑,可以寫個(gè) shell 去循環(huán) restart #
supervisorctl restart program_name:program_name_0
supervisorctl restart program_name:program_name_1
# 這種通配符會(huì)同時(shí)重啟所有進(jìn)程臭蚁,先 stop 所有最铁,再 start 所有讯赏,不夠平滑 #
supervisorctl restart program_name:*
# 更新配置,平滑啟動(dòng) 適用于:修改配置或新增配置 #
supervisorctl reread
supervisorctl update
# 重啟所有進(jìn)程 #
supervisorctl reload