Supervisor记录

Supervisor的安装和配置,直接参考这篇,写得非常到位:https://www.restran.net/2015/10/04/supervisord-tutorial/

今天是第一次用Supervisor,在尝试用它来持久化运行gunicorn + Django应用时,发现老是无法启动gunicorn,报错:

ERROR (spawn error)

又是看error log又是Google搜索,折腾了半天还是搞不定。最后看着supervisor自己的error log发呆了半天:

2016-05-11 21:07:56,073 INFO spawned: ‘lan-server’ with pid 3003
2016-05-11 21:07:56,441 INFO exited: lan-server (exit status 0; not expected)
2016-05-11 21:07:57,464 INFO spawned: ‘lan-server’ with pid 3021
2016-05-11 21:07:57,831 INFO exited: lan-server (exit status 0; not expected)
2016-05-11 21:07:59,837 INFO spawned: ‘lan-server’ with pid 3029
2016-05-11 21:08:00,211 INFO exited: lan-server (exit status 0; not expected)
2016-05-11 21:08:03,220 INFO spawned: ‘lan-server’ with pid 3037
2016-05-11 21:08:03,661 INFO exited: lan-server (exit status 0; not expected)
2016-05-11 21:08:04,663 INFO gave up: lan-server entered FATAL state, too many start retries too quickly

突然间就顿悟了:Supervisor会监控target进程,一旦退出就重启,而我将gunicorn的启动命令写在了一个shell脚本中,并且启用了gunicorn的daemon模式,对应的Supervisor任务command直接是bash xxx.sh,这样一来,bash xxx.sh当然跑了就秒退出,于是Supervisor就不停重启它,直到达到重启上限(默认3次)。

问题的根源就在gunicorn的daemon模式,关闭daemon一试,果然ok。结帖以记之。

Supervisor记录》有2个想法

  1. Pingbacksupervisor manage program with daemon – SRE

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.