我从这里复制了一些内容,以便将我的Python代码作为守护进程运行。为了实现更长的正常运行时间,我认为最好使用supervisor维持此守护进程的运行。
我执行了以下操作。 python_deamon.conf
问题在于,尽管supervisor成功启动了python_daemon,但它仍在不断重试。
只是为了记录,覆盖
我正在尝试做的事情可能有可能吗?还是我很愚蠢?
P.S:我知道整个问题的根本原因是因为run()从不返回任何内容,所以监管者一直在尝试启动它,因此认为进程失败并将状态设置为
P.P.S:独立运行(无监管者)的
我执行了以下操作。 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
问题在于,尽管supervisor成功启动了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()
方法后我从来没有返回任何东西。我正在尝试做的事情可能有可能吗?还是我很愚蠢?
P.S:我知道整个问题的根本原因是因为run()从不返回任何内容,所以监管者一直在尝试启动它,因此认为进程失败并将状态设置为
FATAL Exited too quickly (process log may have details)
。我的实际问题是我这样做对吗?还是可以用这种方式完成?P.P.S:独立运行(无监管者)的
daemon_runnner.py
在有sudo权限和没有sudo权限时都可以正常运行。
daemon_runner.py
的情况下进行过测试?它返回状态码1。 - wenzul