天天看點

Supervisor使用Supervisor

Supervisor

Supervisor是用Python開發的一套通用的程序管理程式,能将一個普通的指令行程序變為背景daemon,并監控程序狀态,異常退出時能自動重新開機。

http://supervisord.org/

安裝

pip3 install supervisor 或 
	yum install supervisor 或 
	apt install supervisor
           

預設安裝最新版

配置

這篇比較詳細

https://www.jianshu.com/p/0b9054b33db3

基本使用指令

supervisord -c ../supervisor.conf
	supervisorctl 
	status
	start
	restart
	stop
	stopall
	reload
           

tips:

command not found

使用pip3 install supervisor完,supervisord supervisorctl echo_supervisord_conf 
這三個工具可能都被放在了 /usr/local/python3/bin
在使用這些指令時,預設是從 /usr/bin/ 找, 是以要先 cp .....  /usr/bin/
           

FATAL Exited too quickly

寫了一個test.py 僅僅輸出一句字元,顯示異常
日志中顯示 "gave up:  entered FATAL state, too many start retries too quickly"
原因在這:
意思就啟動的這個程序必須維持1秒否則視為啟動失敗
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
設定為 startsecs=0