Nag*_*gri 3 python daemon supervisord python-daemon
I copied from here to run my Python code as a daemon. For extra uptime. I thought it would be a better Idea to use supervisor to keep this daemon running.
我这样做了。 python_deamon.conf
[program:python_deamon]
directory=/usr/local/python_deamon/
command=/usr/local/python_venv/bin/python daemon_runnner.py start
stderr_logfile=/var/log/gunicorn.log
stdout_logfile=/var/log/gunicorn.log
autostart=true
autorestart=true
Run Code Online (Sandbox Code Playgroud)
问题是,尽管主管成功启动了 python_daemon,但它一直在重试。
2015-09-23 16:10:45,592 CRIT Supervisor running as root (no user in config file)
2015-09-23 16:10:45,592 WARN Included extra file "/etc/supervisor/conf.d/python_daemon.conf" during parsing
2015-09-23 16:10:45,592 INFO RPC interface 'supervisor' initialized
2015-09-23 16:10:45,592 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-09-23 16:10:45,592 INFO supervisord started with pid 13880
2015-09-23 16:10:46,595 INFO spawned: 'python_deamon' with pid 17884
2015-09-23 16:10:46,611 INFO exited: python_deamon (exit status 1; not expected)
2015-09-23 16:10:47,614 INFO spawned: 'python_deamon' with pid 17885
2015-09-23 16:10:47,630 INFO exited: python_deamon (exit status 1; not expected)
2015-09-23 16:10:49,635 INFO spawned: 'python_deamon' with pid 17888
2015-09-23 16:10:49,656 INFO exited: python_deamon (exit status 1; not expected)
2015-09-23 16:10:52,662 INFO spawned: 'python_deamon' with pid 17891
2015-09-23 16:10:52,680 INFO exited: python_deamon (exit status 1; not expected)
2015-09-23 16:10:53,681 INFO gave up: python_deamon entered FATAL state, too many start retries too quickly
Run Code Online (Sandbox Code Playgroud)
只是为了记录后覆盖 run()
method I never return anything.
有可能做我想做的事情还是我很笨?
PS:我知道整个问题的根本原因是因为 run() 从不返回任何内容,主管一直在尝试启动它,因此认为该过程失败并给出状态为 FATAL Exited too quickly (process log may have details)
.
我的实际问题是我做得对吗?或者可以这样做吗?
PPS:独立(没有主管)daemon_runnner.py
在有和没有 sudo 权限的情况下都可以正常运行。
尝试设置 startsecs = 0:
[program:foo]
command = ls
startsecs = 0
autorestart = false
http://supervisord.org/configuration.html
startsecs
Run Code Online (Sandbox Code Playgroud)
启动后程序需要保持运行以认为启动成功的总秒数。如果程序在启动后没有停留这么多秒,即使它以“预期的”退出代码(参见退出代码)退出,也会认为启动失败。设置为 0 表示程序不需要在任何特定的时间内保持运行。