def SvcDoRun(self): # Write an event log record - in debug mode we will also # see this message printed. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '') ) # attempt to retrieve comnfig file name self._svc_configFile_ = win32serviceutil.GetServiceCustomOption( TaskRunnerService._svc_name_, "TaskConfigurationFile", self._svc_configFile_ ) # Create the active object. self.taskRunner = TaskRunner() self.taskRunner.configure( parseXmlFile( self._svc_configFile_ ) ) self.taskRunner.start() self.running = True while self.running: # it is all on deamon threads time.sleep(1) # Write another event log record. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, "") )
def loadFromFile( self, fileName ): """ Load any handlers specified in the file. """ errCount = 0 if fileName.endswith( ".xml" ): _log.info( "load from file %s" % fileName ) try: xmlDom = parseXmlFile( fileName ) cfgDict = getDictFromXml( xmlDom ) thisCount = self.loadHandlers( cfgDict ) if thisCount > 0: errCount = errCount + thisCount _log.error( "Error configuring event routing using %s" % (fileName) ) except Exception, ex : _log.exception( "Error in %s" % (fileName) ) errCount = errCount + 1