以下是python代码,如何仅使用python 1.py命令将应用程序作为守护进程启动?
import eventlet
from eventlet import wsgi
def hello_world(env, start_response):
if env['PATH_INFO'] != '/':
start_response('404 Not Found', [('Content-Type', 'text/plain')])
return ['Not Found\r\n']
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello, World!\r\n']
wsgi.server(eventlet.listen(('', 8090)), hello_world)发布于 2017-11-06 22:42:03
Supervisor是管理长时间运行的后台进程的一个很好的工具。
安装supervisor,创建一个配置文件,指定要运行的命令、应该运行该命令的用户、日志位置等。
然后,您可以使用sudo supervisorctl start {{ name }}启动该服务,并根据需要使用类似的命令停止它。
发布于 2017-11-06 22:41:37
在CentOS中有许多不同的启动进程的方法,你可以选择哪种方法以你喜欢的方式解决问题。
python 1.py,然后忘记它,直到您关闭计算机nohup python 1.py &,然后关闭终端。即使会话结束,Nohup也会使程序继续运行。如果您需要终止它,您需要使用ps -ax在进程列表中找到它,并使用kill <process_id>https://stackoverflow.com/questions/47139180
复制相似问题