예제 #1
0
                # job started
                pbs_id = res_lines[0].split('.',1)[0]
                job.setTorqueJobId(pbs_id, 'NEW')
                self.Jobs[pbs_id] = job
                    
                sys.stdout.write('Started PBS job id %s, ORA job id %d\n' %\
                        (pbs_id, job_name))

        return list(err_jobs)

if __name__ == '__main__':
    daemon = Poller('/tmp/qiime-webapp-poller.pid',
                    stdout='/tmp/qiime-webapp-poller.stdout',
                    stderr='/tmp/qiime-webapp-poller.stderr')

    if len(sys.argv) >= 2:
        if 'start' == sys.argv[1]:
            daemon.start()
        elif 'stop' == sys.argv[1]:
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            daemon.restart()
        else:
            print "Unknown command"
            sys.exit(2)
        sys.exit(0)
    else:
        print "usage: %s start|stop|restart" % sys.argv[0]
        sys.exit(2)

예제 #2
0
from time import sleep

class TestDaemon(Daemon):
    def __init__(self, *args, **kwargs):
        self.interval = 0
        super(TestDaemon, self).__init__(*args, **kwargs)

    def run(self):
        while True:
            self.interval += 1
            sleep(5)
            print self.interval

            sys.stdout.flush()
            sys.stderr.flush()
if __name__ == '__main__':
    daemon = TestDaemon('/tmp/testdaemon.pid',
            stdout='/tmp/testdaemon.stdout',
            stderr='/tmp/testdaemon.stderr')

    if len(sys.argv) >= 2:
        if 'start' == sys.argv[1]:
            daemon.start()
        elif 'stop' == sys.argv[1]:
            daemon.stop()
        else:
            print "needs start or stop"
            sys.exit(2)
    else:
        print "wtf... gimme a start or stop"