def run(self): """ Start the bus and blocks on the Axon scheduler. """ self.log("TornadoProcess PID: %d" % (self.pid or os.getpid(), )) from cherrypy.process import plugins sig = plugins.SignalHandler(self.bus) if sys.platform[:4] == 'java': # See http://bugs.jython.org/issue1313 sig.handlers['SIGINT'] = self._jython_handle_SIGINT sig.subscribe() self.bus.start() try: from tornado import ioloop self.ioloop = ioloop.IOLoop.instance() self.ioloop.add_callback(self.publish_main) self.ioloop.start() except KeyboardInterrupt: pass ioloop.IOLoop.instance().stop() self.bus.exit()
def run(self): """ Start the bus and blocks on the Axon scheduler. """ self.log("AsyncoreProcess PID: %d" % (self.pid or os.getpid(), )) self.bus.subscribe('main', self.loop_once) from cherrypy.process import plugins sig = plugins.SignalHandler(self.bus) if sys.platform[:4] == 'java': # See http://bugs.jython.org/issue1313 sig.handlers['SIGINT'] = self._jython_handle_SIGINT sig.subscribe() self.bus.start() self.bus.block(interval=self.interval)
def modifySignalHandlers(self, engine): pluginsSignalHandler = plugins.SignalHandler(engine) handlers = pluginsSignalHandler.handlers # Add handler for interrupt handlers['SIGINT'] = engine.exit # Modify all signal handlers for signal in handlers.keys(): self.logger.debug('Modifying signal: %s' % signal) oldSignalHandler = handlers[signal] self.logger.debug('Old signal handler: %s' % oldSignalHandler) signalHandler = CdbWebServiceBase.SignalHandler( signal, oldSignalHandler) self.logger.debug('Setting signal handler to: %s' % signalHandler.signalHandler) handlers[signal] = signalHandler.signalHandler pluginsSignalHandler.subscribe()
def run(self): """ Start the bus and blocks on the bus. """ self.log("Process PID: %d" % (self.pid or os.getpid(), )) from cherrypy.process import plugins sig = plugins.SignalHandler(self.bus) if sys.platform[:4] == 'java': # See http://bugs.jython.org/issue1313 sig.handlers['SIGINT'] = self._jython_handle_SIGINT sig.subscribe() if self.daemon: plugins.Daemonizer(self.bus).subscribe() self.bus.start() self.bus.block(interval=self.interval)
def run(self): self.service_state.workers = self.handler.workers daemon = plugins.Daemonizer( cherrypy.engine, stdout=os.path.join(self.workdir, 'fioservice.access.log'), stderr=os.path.join(self.workdir, 'fioservice.log'), ) daemon.subscribe() cherrypy.log.error_log.propagate = False cherrypy.log.access_log.propagate = False cherrypy.server.socket_host = configuration.settings.ip_address cherrypy.tree.mount(self.root, config=self.conf) cherrypy.config.update({ 'engine.autoreload.on': False, 'server.socket_host': configuration.settings.ip_address, 'server.socket_port': configuration.settings.port, 'error_page.default': jsonify_error, 'tools.encode.encoding': 'utf-8', 'cors.expose.on': True, }) plugins.PIDFile(cherrypy.engine, get_pid_file(self.workdir)).subscribe() plugins.SignalHandler(cherrypy.engine).subscribe() # handle SIGTERM, SIGHUP etc self.worker = plugins.BackgroundTask( interval=1, function=run_job, args=[self.dbpath, self.handler, self.service_state, self.debug_mode] ) cherrypy.engine.subscribe('stop', self.cleanup) try: cherrypy.engine.start() except Exception: sys.exit(1) else: self.worker.run() cherrypy.engine.block()
def run(self): self.service_state.workers = self.handler.workers daemon = plugins.Daemonizer( cherrypy.engine, stdout=os.path.join(self.workdir, 'fioservice.access.log'), stderr=os.path.join(self.workdir, 'fioservice.log'), ) daemon.subscribe() cherrypy.log.error_log.propagate = False cherrypy.log.access_log.propagate = False cherrypy.server.socket_host = '0.0.0.0' cherrypy.tree.mount(self.root, config=self.conf) cherrypy.config.update({ 'engine.autoreload.on': False, 'server.socket_host': '0.0.0.0', 'server.socket_port': self.port }) plugins.PIDFile(cherrypy.engine, get_pid_file(self.workdir)).subscribe() plugins.SignalHandler( cherrypy.engine).subscribe() # handle SIGTERM, SIGHUP etc self.worker = plugins.BackgroundTask( interval=1, function=run_job, args=[self.handler, self.service_state]) cherrypy.engine.subscribe('stop', self.cleanup) # prevent CP loggers from propagating entries to the root logger # (i.e stop duplicate log entries) try: cherrypy.engine.start() except Exception: sys.exit(1) else: self.worker.run() cherrypy.engine.block()
def run(self): """ Start the bus and blocks on the Axon scheduler. """ self.log("AxonProcess PID: %d" % (self.pid or os.getpid(), )) from conductor.lib.keepalive import KeepSchedulerAlive self.keepalive = KeepSchedulerAlive(bus=self.bus) self.keepalive.activate() from cherrypy.process import plugins sig = plugins.SignalHandler(self.bus) if sys.platform[:4] == 'java': # See http://bugs.jython.org/issue1313 sig.handlers['SIGINT'] = self._jython_handle_SIGINT sig.subscribe() self.bus.start() try: from Axon.Scheduler import scheduler scheduler.run.runThreads(slowmo=self.interval) except KeyboardInterrupt: pass self.bus.exit()