相关疑难解决方法(0)

如何使Python脚本像Linux中的服务或守护程序一样运行

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

python linux scripting daemons

163
推荐指数
11
解决办法
26万
查看次数

Run a python script with supervisor

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)

python daemon supervisord python-daemon

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×2

daemon ×1

daemons ×1

linux ×1

python-daemon ×1

scripting ×1

supervisord ×1