I m using the template python daemon discussed here in two different scripts to launch two separate daemons. I would like to combine them into one daemon script that has one lockfile, etc. However, each has different loop timer, one at 1 minute and the other at 5 minutes. I m starting with this:
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()
The obvious thing to do would be to create another class but I want the basic stuff like pidfile to remain constant.