supervisor 启动python脚本失败
问题: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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前该问题已经解决,原因是题主在修改 supervisor 配置后,没有 reload 配置。
检查一下supervisor安装时用的python版本是否和python命令版本一致