我编写了一个Python脚本,用于检查某个电子邮件地址并将新电子邮件传递给外部程序.如何让这个脚本全天候执行,例如将其转换为Linux中的守护程序或服务.我是否还需要一个永远不会在程序中结束的循环,或者可以通过多次执行代码来完成它?
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 …Run Code Online (Sandbox Code Playgroud)