[英]Simple HTTPServer python on background
I have this script, I do not know how to have it running in the background, cause when i close the session it close too. 我有这个脚本,我不知道如何让它在后台运行,因为当我关闭它关闭会话时也是如此。 I tried putting it on crontab but not find the index.html and shows the list of files in /. 我尝试将它放在crontab上但找不到index.html并显示/中的文件列表。
#! /opt/python3/bin/python3
from http.server import HTTPServer, CGIHTTPRequestHandler
port = 8000
httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
print("Starting simple_httpd on port: " + str(httpd.server_port))
httpd.serve_forever()`
Basically you are asking about how to detach the program from your shell ... here is a few options 基本上你问的是如何从shell中分离程序...这里有几个选项
Update: 更新:
Recently I have not written a single daemon in python. 最近我没有在python中编写一个守护进程。 The days of forking twice or using a daemon library seem to be well behind us. 分叉两次或使用守护程序库的日子似乎已经远远落后于我们。 I currently use supervisord and have heard good things about circus . 我目前使用supervisord并听说过关于马戏团的好东西。 These are just a small set of extra options you can use to deploy python daemons. 这些只是可用于部署python守护进程的一小部分额外选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.