import platform

class ServiceApp():

    def __init__(self, name, runnable):
        self.stdin_path = '/dev/null'
        self.stdout_path = '/dev/tty'
        self.stderr_path = '/dev/tty'
        self.pidfile_path =  '/var/run/ardi/' + name + '.pid'
        self.pidfile_timeout = 5
        self.runnable = runnable

    def start(self):
        if (platform.system() != 'Windows'):
            import daemon
            from daemon import runner
        
            daemon_runner = runner.DaemonRunner(self)        
            daemon_runner.do_action()
        else:
            self.runnable();
       
    def run(self):
        while True:
            #Main code goes here ...
            self.runnable()
      