def start_app_engines(self): """Start the app for the start subcommand.""" config = self.master_config # First see if the cluster is already running # Now log and daemonize self.log.info( 'Starting engines with [daemon=%r]' % config.Global.daemonize ) # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name=='posix': from twisted.scripts._twistd_unix import daemonize daemonize() # Now write the new pid file AFTER our new forked pid is active. # self.write_pid_file() try: self.loop.start() except KeyboardInterrupt: pass except zmq.ZMQError as e: if e.errno == errno.EINTR: pass else: raise
def start_app_start(self): """Start the app for the start subcommand.""" config = self.master_config # First see if the cluster is already running try: pid = self.get_pid_from_file() except PIDFileError: pass else: self.log.critical( 'Cluster is already running with [pid=%s]. ' 'use "ipcluster stop" to stop the cluster.' % pid ) # Here I exit with a unusual exit status that other processes # can watch for to learn how I existed. self.exit(ALREADY_STARTED) # Now log and daemonize self.log.info( 'Starting ipcluster with [daemon=%r]' % config.Global.daemonize ) # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name=='posix': daemonize() # Now write the new pid file AFTER our new forked pid is active. self.write_pid_file() reactor.addSystemEventTrigger('during','shutdown', self.remove_pid_file) reactor.run()
def start_app_start(self): """Start the app for the start subcommand.""" config = self.master_config # First see if the cluster is already running try: pid = self.get_pid_from_file() except PIDFileError: pass else: self.log.critical('Cluster is already running with [pid=%s]. ' 'use "ipcluster stop" to stop the cluster.' % pid) # Here I exit with a unusual exit status that other processes # can watch for to learn how I existed. self.exit(ALREADY_STARTED) # Now log and daemonize self.log.info('Starting ipcluster with [daemon=%r]' % config.Global.daemonize) # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name == 'posix': daemonize() # Now write the new pid file AFTER our new forked pid is active. self.write_pid_file() reactor.addSystemEventTrigger('during', 'shutdown', self.remove_pid_file) reactor.run()
def start_app_engines(self): """Start the app for the start subcommand.""" config = self.master_config # First see if the cluster is already running # Now log and daemonize self.log.info('Starting engines with [daemon=%r]' % config.Global.daemonize) # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name == 'posix': from twisted.scripts._twistd_unix import daemonize daemonize() # Now write the new pid file AFTER our new forked pid is active. # self.write_pid_file() try: self.loop.start() except KeyboardInterrupt: pass except zmq.ZMQError as e: if e.errno == errno.EINTR: pass else: raise
def __init__(self): # Check for any other instances if config.pid and os.name != "posix": config.pid = "" if config.pid: twistd.checkPID(config.pid) # Do any auto-update stuff xdb.housekeep() # Daemonise the process and write the PID file if daemonizeme and os.name == "posix": twistd.daemonize() if config.pid: self.writePID() jid = config.jid if config.useXCP and config.compjid: jid = config.compjid if config.saslUsername: import sasl self.c = sasl.buildServiceManager(jid, config.saslUsername, config.secret, "tcp:%s:%s" % (config.mainServer, config.port)) else: self.c = component.buildServiceManager(jid, config.secret, "tcp:%s:%s" % (config.mainServer, config.port)) self.transportSvc = PyTransport() self.transportSvc.setServiceParent(self.c) self.c.startService() reactor.addSystemEventTrigger('before', 'shutdown', self.shuttingDown)
def test_daemonizationHooksNotCalled(self): """ L{_twistd_unix.daemonize} does NOT call L{IReactorDaemonize.beforeDaemonize} or L{IReactorDaemonize.afterDaemonize} if the reactor does NOT implement L{IReactorDaemonize}. """ reactor = FakeNonDaemonizingReactor() os = MockOS() _twistd_unix.daemonize(reactor, os) self.assertFalse(reactor._beforeDaemonizeCalled) self.assertFalse(reactor._afterDaemonizeCalled)
def test_daemonizationHooksCalled(self): """ L{_twistd_unix.daemonize} indeed calls L{IReactorDaemonize.beforeDaemonize} and L{IReactorDaemonize.afterDaemonize} if the reactor implements L{IReactorDaemonize}. """ reactor = FakeDaemonizingReactor() os = MockOS() _twistd_unix.daemonize(reactor, os) self.assertTrue(reactor._beforeDaemonizeCalled) self.assertTrue(reactor._afterDaemonizeCalled)
def start_app_start(self): """Start the app for the start subcommand.""" config = self.master_config # First see if the cluster is already running try: pid = self.get_pid_from_file() except PIDFileError: pass else: if self.check_pid(pid): self.log.critical( 'Cluster is already running with [pid=%s]. ' 'use "ipcluster stop" to stop the cluster.' % pid ) # Here I exit with a unusual exit status that other processes # can watch for to learn how I existed. self.exit(ALREADY_STARTED) else: self.remove_pid_file() # Now log and daemonize self.log.info( 'Starting ipcluster with [daemon=%r]' % config.Global.daemonize ) # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name=='posix': from twisted.scripts._twistd_unix import daemonize daemonize() # Now write the new pid file AFTER our new forked pid is active. self.write_pid_file() try: self.loop.start() except KeyboardInterrupt: pass except zmq.ZMQError as e: if e.errno == errno.EINTR: pass else: raise finally: self.remove_pid_file()
def start_app_start(self): """Start the app for the start subcommand.""" config = self.master_config # First see if the cluster is already running try: pid = self.get_pid_from_file() except PIDFileError: pass else: self.log.critical('Cluster is already running with [pid=%s]. ' 'use "ipcluster stop" to stop the cluster.' % pid) # Here I exit with a unusual exit status that other processes # can watch for to learn how I existed. self.exit(ALREADY_STARTED) # Now log and daemonize self.log.info('Starting ipcluster with [daemon=%r]' % config.Global.daemonize) # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name == 'posix': from twisted.scripts._twistd_unix import daemonize daemonize() # Now write the new pid file AFTER our new forked pid is active. self.write_pid_file() try: self.loop.start() except KeyboardInterrupt: pass except zmq.ZMQError as e: if e.errno == errno.EINTR: pass else: raise self.remove_pid_file()