问题:supervisor 启动 python 脚本失败
supervisor配置如下
[supervisord]
nodaemon=false
[program:app]
command=python /path/to/app/report.py
autostart=true
autorestart=true
startsecs=3
stdout_logfile=/path/to/app/info.log
stderr_logfile=/path/to/app/err.log
report.py 内容(功能每分钟请求一次指定接口)
使用 python report.py 执行没有问题
import requests
import random
import time
def do_something():
while True:
params = (
('foo', 'foo'),
('bar', 'bar'),
)
r = requests.get('http://url/report.php', params=params)
print(r.url)
print(r.text)
time.sleep(60)
if __name__ == "__main__":
do_something()
报错信息
$ supervisorctl start app
app: ERROR (spawn error)
$ supervisorctl status
app BACKOFF Exited too quickly (process log may have details)
$ tail -f /tmp/supervisord.log
2017-10-16 16:40:01,768 INFO gave up: app entered FATAL state, too many start retries too quickly
2017-10-17 10:59:54,412 INFO spawned: 'app' with pid 6648
2017-10-17 10:59:54,440 INFO exited: app (exit status 1; not expected)
2017-10-17 10:59:55,445 INFO spawned: 'app' with pid 6649
2017-10-17 10:59:55,473 INFO exited: app (exit status 1; not expected)
2017-10-17 10:59:57,478 INFO spawned: 'app' with pid 6650
2017-10-17 10:59:57,507 INFO exited: app (exit status 1; not expected)
2017-10-17 11:00:01,173 INFO spawned: 'app' with pid 6653
2017-10-17 11:00:01,201 INFO exited: app (exit status 1; not expected)
2017-10-17 11:00:02,203 INFO gave up: app entered FATAL state, too many start retries too quickly
目前该问题已经解决,原因是题主在修改 supervisor 配置后,没有 reload 配置。