1. 安装 sudo pip install supervisor
2. 添加配置文件: sudo echo_supervisord_conf > /etc/supervisord.conf
3. 设置开机启动:
Supervisor is not running at startup. You can configure an init.d script to do this.
sudo vi /etc/init.d/supervisord
Add the following:
# Supervisord auto-start
#
# description: Auto-starts supervisord
# processname: supervisord
# pidfile: /var/run/supervisord.pid
SUPERVISORD=/usr/local/bin/supervisord
SUPERVISORCTL=/usr/local/bin/supervisorctl
case $1 in
start)
echo -n "Starting supervisord: "
$SUPERVISORD
echo
;;
stop)
echo -n "Stopping supervisord: "
$SUPERVISORCTL shutdown
echo
;;
restart)
echo -n "Stopping supervisord: "
$SUPERVISORCTL shutdown
echo
echo -n "Starting supervisord: "
$SUPERVISORD
echo
;;
esac
And then...
sudo chmod +x /etc/init.d/supervisord
sudo update-rc.d supervisord defaults
sudo /etc/init.d/supervisord start
Obviously, this should probably go as added actions on cookbook.py and the init.d script as a template
遇到的问题
exit too quick
这个可能是某些python的库没有安装,然后也不报错
还有可能是之前启动没有成功,但是进程已经存在了,这里要手工kill掉之前的app进程再stall all
abnormal termination:
这个可以这样测试,如果不用supervisord来管理能正常运行的话,那一般是代码中可能有输出异常字符,比如中文什么的,解决办法有几个,最简单的就是去掉类似print 输出中文的地方 , 这个错误很郁闷,不会报错,但就是用supervisord运行不起来