我使用< a href=> https://stackoverflow.com/ questions/473620/how-do-you-deposition- a-daemon- in-python>>>template python 守护程序在这里讨论过的两种不同的脚本 来启动两个独立的守护程序。 我想把它们合并成一个包含一个锁定文件等的守护程序脚本。 但是,每个脚本都有不同的循环计时器, 一个在1分钟内,另一个在5分钟内。
import os
import subprocess
import time
from daemon import runner
class App():
def __init__(self):
self.stdin_path = /dev/null
self.stdout_path = /dev/tty
self.stderr_path = /dev/tty
self.pidfile_path = /tmp/test.pid
self.pidfile_timeout = 5
def run(self):
try:
while True:
print "hello!"
# set the sleep time for repeated action here:
time.sleep(1)
except Exception, e:
raise
app = App()
daemon_runner = runner.DaemonRunner(app)
daemon_runner.do_action()
显而易见的是 要再造一个班级 但我想让Pidfile这种基本的东西 保持恒定不变