从Python启动Linux守护程序 [英] Start a Linux daemon from Python
问题描述
一个简单的问题
我正在使用Django中的python脚本从网页启动linux守护程序(运动)。当我使用以下命令时:
I'm starting a linux daemon (motion) from a webpage using a python script inside Django. When I use the following:
def restartRecord():
#restart the service
config_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'recorder/config/motion.conf')
p = subprocess.call(['motion', '-c', config_file])
return True
启动守护程序没问题,但同时也绑定了如果我正在从django开发服务器(端口8000)运行它,请使用该端口。这是正常行为吗? -为什么启动守护程序会占用该端口?我可以通过停止开发服务器并尝试再次启动它来进行测试。
It starts the daemon no problem, but it also ties up the port if I'm using running it from the django development server (port 8000). Is this the normal behaviour? - Why would starting the daemon tie up that port? I can test this by stopping the development server and trying to start it again.
是否有更好的方法来启动此服务?
Is there a better way to start this service?
干杯,
Ben
Cheers, Ben
推荐答案
在apache下工作正常,这是主要问题。感谢您的答复。
It seems to work fine under apache which is the main thing. Thanks for the replies.
这篇关于从Python启动Linux守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!