def open(self): if not workerConfig.has_section('server') or not workerConfig.has_option('server', 'broker'): raise EnvironmentError('Cannot find taskmodule url') self.urlAMQP = workerConfig.get('server', 'broker') self.amqpProducer = producer.AMQPProducer(url=self.urlAMQP)
worker['lastEvtId'] = None self.metaClient = meta.MetaHandler(hosts=ZK_URL, nodeInfo=worker, eventCallback=self.__metaEventHandler) # update global (server-side) configuration try: workerConfig.update(self.metaClient.getConfig(), keepOrgValue=True) except Exception, e: log.error("Meta Configuration error - %s" % e) log.debug(dict(workerConfig.items('db'))) if workerConfig.has_section('db'): dbmanager.initDbParams(dict(workerConfig.items('db'))) if workerConfig.has_section('server') and workerConfig.has_option('server', 'task_module'): self.moduleClient = module.TaskModule(workerConfig.get('server', 'task_module')) if self.environment == 'production': self.downloadModules() self.taskClient = task.TaskManager(self.metaClient) self.slotPool = slot.SlotPool() self.slotPool.open() def __signalHandler(self, signum, frame): self.stop() def __metaEventHandler(self, event, evtObj=None): log.debug("Receive Meta Event - %s, %s" % (event, evtObj))