Trees | Indices | Help |
|
---|
|
1 ########################################################################### 2 # 3 # This program is part of Zenoss Core, an open source monitoring platform. 4 # Copyright (C) 2009, Zenoss Inc. 5 # 6 # This program is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 as published by 8 # the Free Software Foundation. 9 # 10 # For complete information please visit: http://www.zenoss.com/oss/ 11 # 12 ########################################################################### 13 14 import sys 15 import time 16 import logging 17 from Globals import * 18 from twisted.internet import reactor, defer 19 from Products.ZenUtils.CyclingDaemon import CyclingDaemon 20 import transaction 21 from status import FAILURE 22 23 logger = logging.getLogger('zen.Jobs') 24 logger.setLevel(20) 2527 """ 28 Daemon to run jobs. 29 """ 30 name = 'zenjobs' 3189 90 if __name__ == "__main__": 91 zj = ZenJobs() 92 zj.run() 9333 CyclingDaemon.__init__(self, *args, **kwargs) 34 self.jm = self.dmd.JobManager 35 self.runningjobs = []3638 logger.info("Starting %s %s" % ( 39 job.getJobType(), 40 job.getDescription())) 41 self.runningjobs.append(job.start()) 42 # Zope will want to know the job has started 43 transaction.commit() 44 job.getStatus().waitUntilFinished().addCallback(self.job_done)4547 logger.info('%s %s completed in %s seconds.' % ( 48 jobstatus.getJob().getJobType(), 49 jobstatus.getJob().getDescription(), 50 jobstatus.getDuration())) 51 # Zope will want to know the job has finished 52 transaction.commit()5355 return defer.DeferredList(self.runningjobs)56 6163 if self.options.cycle: 64 self.sendHeartbeat() 65 reactor.callLater(self.options.cycletime, self.runCycle) 66 else: 67 # Can't stop the reactor until jobs are done 68 whenDone = self.waitUntilRunningJobsFinish() 69 whenDone.addBoth(self.finish)7072 try: 73 start = time.time() 74 self.syncdb() 75 self.main_loop() 76 except: 77 self.log.exception("unexpected exception")78 8183 for d in self.runningjobs: 84 try: 85 d.callback(FAILURE) 86 except defer.AlreadyCalledError: 87 pass 88 CyclingDaemon.finish(self, r)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:41 2009 | http://epydoc.sourceforge.net |