Exemple #1
0
 def stopService(self):
     try:
         file_cache_idxs = MetricCache.getAllFileCaches()
         writeCachedDataPointsWhenStop(file_cache_idxs)
     except Exception as e:
         log.err('write error when stopping service: %s' % e)
     Service.stopService(self)
Exemple #2
0
 def stopService(self):
     """
     Stop service by stopping the timerservice and disconnecting cass client
     """
     Service.stopService(self)
     d = self._service.stopService()
     return d.addCallback(lambda _: self._client.disconnect())
Exemple #3
0
 def stopService(self):
     """
     Stop ThreadWrapper
     :return:
     """
     self.q.put((None, None, None, None))
     Service.stopService(self)
Exemple #4
0
    def main(self):
        """Parse arguments and run the script's main function via ``react``."""
        # If e.g. --version is called this may throw a SystemExit, so we
        # always do this first before any side-effecty code is run:
        options = self._parse_options(self.sys_module.argv[1:])

        if self.logging:
            log_writer = eliot_logging_service(options.eliot_destination,
                                               self._reactor, True)
        else:
            log_writer = Service()
        log_writer.startService()

        # XXX: We shouldn't be using this private _reactor API. See
        # https://twistedmatrix.com/trac/ticket/6200 and
        # https://twistedmatrix.com/trac/ticket/7527
        def run_and_log(reactor):
            d = maybeDeferred(self.script.main, reactor, options)

            def got_error(failure):
                if failure.check(UsageError):
                    err(failure.value.args)
                    raise SystemExit(1)
                elif not failure.check(SystemExit):
                    err(failure)
                return failure

            d.addErrback(got_error)
            return d

        try:
            self._react(run_and_log, [], _reactor=self._reactor)
        finally:
            log_writer.stopService()
Exemple #5
0
 def stopService(self):
     Service.stopService(self)
     try:
         self.app.close()
     except Exception:
         logger.error('Error while closing application', exc_info=True)
     self._close_database()
Exemple #6
0
 def stopService(self):
     """
     Stop the service by calling stored function
     """
     Service.stopService(self)
     if self._stop:
         return self._stop()
Exemple #7
0
	def stopService(self):
		if self.running:
			Service.stopService(self)
			log.info("Stopping master heartbeat service...")
			return self._hb.stop()
		else:
			return defer.succeed(None)
 def stopService(self):
     # We don't need to call port.stopListening(), because the reactor
     # shutdown sequence will do that for us.
     Service.stopService(self)
     logging.info("%s stopped with config %s" %
                  (self.service_name.capitalize(),
                   self.config.get_config_filename()))
Exemple #9
0
 def stopService(self):
     try:
         file_cache_idxs = MetricCache.getAllFileCaches()
         writeCachedDataPointsWhenStop(file_cache_idxs)
     except Exception as e:
         log.err('write error when stopping service: %s' % e)
     Service.stopService(self)
 def stopService(self):
     print 'Stop PullRequest service: %s ...' % self.context.name
     Service.stopService(self)
     if self.watchLoop:
         self.watchLoop.stop()
     if self.schedulerLoop:
         self.schedulerLoop.stop()
Exemple #11
0
 def stopService(self):
     """
     Stop service by stopping the timerservice and disconnecting cass client
     """
     Service.stopService(self)
     d = self._service.stopService()
     return d.addCallback(lambda _: self._client.disconnect())
Exemple #12
0
		def s2(code, self=self):
			try:
				if code != 1:
					# Cancel stop
					return

				if not (self._state == 'stopping' and (self._process + self._workers) == 0):
					err(RuntimeError('{0} stop error: state-{1} p{2} w{3}'.format(
						self.name,
						self._state,
						self._process,
						self._workers,
					)))

				self._stopCall = None
				self._stopDeferred = None

				# Inside
				Service.stopService(self)

				self._state = 'stopped'

				# Show info
				msg(self.name, 'stopped', system='-')
			except:
				err()
Exemple #13
0
 def stopService(self):
     Service.stopService(self)
     try:
         self.app.close()
     except Exception:
         logger.error('Error while closing application', exc_info=True)
     self._close_database()
Exemple #14
0
 def stopService(self):
     ntasks = len(self._tasks)
     for task in self.iterTasks():
         task.close()
     self._tasks = set()
     Service.stopService(self)
     logger.debug("stopped scheduler (%i tasks killed)" % ntasks)
Exemple #15
0
    def main(self):
        """Parse arguments and run the script's main function via ``react``."""
        # If e.g. --version is called this may throw a SystemExit, so we
        # always do this first before any side-effecty code is run:
        options = self._parse_options(self.sys_module.argv[1:])

        if self.logging:
            log_writer = eliot_logging_service(
                options.eliot_destination, self._reactor, True
            )
        else:
            log_writer = Service()
        log_writer.startService()

        # XXX: We shouldn't be using this private _reactor API. See
        # https://twistedmatrix.com/trac/ticket/6200 and
        # https://twistedmatrix.com/trac/ticket/7527
        def run_and_log(reactor):
            d = maybeDeferred(self.script.main, reactor, options)

            def got_error(failure):
                if not failure.check(SystemExit):
                    err(failure)
                return failure
            d.addErrback(got_error)
            return d
        try:
            self._react(run_and_log, [], _reactor=self._reactor)
        finally:
            log_writer.stopService()
Exemple #16
0
 def stopService(self):
     """
     Stops the loop that fetches mail.
     """
     if self._loop and self._loop.running is True:
         self._loop.stop()
         self._loop = None
     Service.stopService(self)
Exemple #17
0
 def stopService(self):
     Service.stopService(self)
     if self.__ws_port_obj is None:
         raise Exception('Not started, cannot stop')
     # TODO: Does Twisted already have something to bundle up a bunch of ports for shutdown?
     return defer.DeferredList([
         self.__http_port_obj.stopListening(),
         self.__ws_port_obj.stopListening()])
Exemple #18
0
 def stopService(self):
     Service.stopService(self)
     if self.__ws_port_obj is None:
         raise Exception('Not started, cannot stop')
     # TODO: Does Twisted already have something to bundle up a bunch of ports for shutdown?
     return defer.DeferredList([
         self.__http_port_obj.stopListening(),
         self.__ws_port_obj.stopListening()])
Exemple #19
0
 def stopService(self):
     Service.stopService(self)
     self.ready = False
     self._registered = False
     for d in list(self._waiting):
         d.cancel()
     self._waiting = []
     return self._timer_service.stopService()
Exemple #20
0
 def stopService(self):
     Service.stopService(self)
     self.ready = False
     self._registered = False
     for d in list(self._waiting):
         d.cancel()
     self._waiting = []
     return self._timer_service.stopService()
Exemple #21
0
    def stopService(self, stopReactor=False):
        Service.stopService(self)
        if self.pipeline is not None:
            self.forceEos()
        else:
            self.shutdown(EXIT_OK, stopReactor)

        return self.shutdownDeferred
Exemple #22
0
 def stopService(self):
     "Stop reading from the stream."
     ret = None
     if self._streamDone is not None:
         self._streamDone.cancel()
         ret = self._streamDone
         self._streamDone = None
     Service.stopService(self)
     return ret
Exemple #23
0
 def stopService(self):
     Event('instance-started').unsubscribe(self.write)
     Event('signal').unsubscribe(self.write)
     Event('journal-error').unsubscribe(self._journal_failure)
     if self._task.running: self._task.stop()
     if not self.writing.called:
         self.writing.addBoth(lambda x: Service.stopService(self) and x or x)
         return self.writing #the main service will deal with it
     Service.stopService(self)
Exemple #24
0
	def stopService(self):
		if self.running:
			Service.stopService(self)
			log.info("Stopping slave heartbeats...")
			if self._call.running:
				self._call.stop()
			return self._hb.stop()
		else:
			return defer.succeed(None)
 def stopService(self):
     """
     Stop reading on the inherited port.
     """
     Service.stopService(self)
     # XXX stopping should really be destructive, because otherwise we will
     # always leak a file descriptor; i.e. this shouldn't be restartable.
     # XXX this needs to return a Deferred.
     self.reportingFactory.inheritedPort.stopReading()
Exemple #26
0
 def stopService(self):
     # annoince to matchmaker that server is shut down
     # try:
     #     res = requests.delete(HUB+"/api/v1.0/register", json={"port": self.port, "id": self.node_id}, timeout=2)
     # except requests.exceptions.RequestException as e:
     #     log.error("Could not notify hub due to request error: {}".format(e))
     # else:
     #     log.info("Service stop, notified hub with code {}".format(res.status_code))
     Service.stopService(self)
Exemple #27
0
 def stopService(self):
     """Stop All Janitizer Service"""
     try:
         if self.GARBAGE_CHECK.running:
             self.GARBAGE_CHECK.stop()
         if self.ELDERLY_CHECK.running:
             self.ELDERLY_CHECK.stop()
     except: pass
     Service.stopService(self)
Exemple #28
0
 def stopService(self):
     """
     Shutdown HiiTrack.
     """
     self.log()
     self.logloop.stop()
     Service.stopService(self)
     cassandra.CLIENT.stopService()
     if self.listener:
         self.listener.stopListening()
Exemple #29
0
 def stopService(self):
     """Stop All Janitizer Service"""
     try:
         if self.GARBAGE_CHECK.running:
             self.GARBAGE_CHECK.stop()
         if self.ELDERLY_CHECK.running:
             self.ELDERLY_CHECK.stop()
     except:
         pass
     Service.stopService(self)
Exemple #30
0
 def stopService(self):
     """
     Stop the writer thread, wait for it to finish.
     """
     Service.stopService(self)
     removeDestination(self)
     self._reactor.callFromThread(self._reactor.stop)
     return deferToThreadPool(
         self._mainReactor, self._mainReactor.getThreadPool(), self._thread.join
     )
Exemple #31
0
 def stopService(self):
     """
     Stop the writer thread, wait for it to finish.
     """
     Service.stopService(self)
     removeDestination(self)
     self._reactor.callFromThread(self._reactor.stop)
     return deferToThreadPool(self._mainReactor,
                              self._mainReactor.getThreadPool(),
                              self._thread.join)
Exemple #32
0
    def stopService(self):
        Service.stopService(self)
        self.ready = False
        self._registered = False
        for d in list(self._waiting):
            d.cancel()
        self._waiting = []

        deferred = self._client.stop()
        deferred.addCallback(lambda _: self._timer_service.stopService())
        return deferred
    def stopService(self):
        info("Stopping client...")
        Service.stopService(self)

        # If CTRL-C is pressed twice in a row, the second SIGINT actually
        # kills us before subprocesses die, and that makes them hang around.
        signal.signal(signal.SIGINT, signal.SIG_IGN)

        done = self.watchdog.request_exit()
        done.addBoth(lambda r: self._remove_pid())
        return done
Exemple #34
0
 def stopService(self):
     self.statusIcon.hide()
     # HACK: the timer should always be running and there's no need for this
     #        check; however, during development the service might be
     #        uncleanly with the timer not running, and then we'd rather
     #        avoid 'trying to stop a timer which isn't running' exception
     if self.timer.running:
         self.timer.stop()
     self.connectionRegistry.updateConfiguration()
     self.configuration.save()
     Service.stopService(self)
Exemple #35
0
    def stopService(self):
        if self.running:
            Service.stopService(self)
            log.info("Stopping RPC service...")

            d1 = defer.maybeDeferred(self._remotePort.stopListening)
            d2 = defer.maybeDeferred(self._localPort.stopListening)
            d2.addBoth(self.cleanSocket)
            return defer.DeferredList([d1, d2])
        else:
            return defer.succeed(None)
Exemple #36
0
	def stopService(self):
		if self.running:
			Service.stopService(self)
			log.info("Stopping RPC service...")

			d1=defer.maybeDeferred(self._remotePort.stopListening)
			d2=defer.maybeDeferred(self._localPort.stopListening)
			d2.addBoth(self.cleanSocket)
			return defer.DeferredList([d1, d2])
		else:
			return defer.succeed(None)
Exemple #37
0
 def stopService(self):
     Service.stopService(self)
     if self._stream_protocol is not None:
         self._stream_protocol.transport.stopProducing()
     if self._reconnect_delayedcall is not None:
         self._reconnect_delayedcall.cancel()
         self._reconnect_delayedcall = None
     if self._connect_d is not None:
         self._connect_d.addErrback(lambda f: f.trap(CancelledError))
         self._connect_d.cancel()
         self._connect_d = None
     self.reconnect_delay = 0
Exemple #38
0
    def stopService(self):
        if self.running:
            Service.stopService(self)

            try:
                self._process.signalProcess('TERM')
            except:
                pass

            try:
                reactor.stop()
            except:
                pass
Exemple #39
0
	def stopService(self):
		if self.running:
			Service.stopService(self)

			try:
				self._process.signalProcess('TERM')
			except:
				pass

			try:
				reactor.stop()
			except:
				pass
Exemple #40
0
    def stopService(self):
        Service.stopService(self)
        if self._socket is not None:
            d = defer.maybeDeferred(self._socket.stopListening)
        else:
            d = defer.succeed(None)

        def loseConnection(_ignored):
            if self.factory.protocol and self.factory.protocol.transport is not None:
                self.factory.protocol.transport.loseConnection()

        d.addCallback(loseConnection)
        return d
Exemple #41
0
 def stopService(self):
     Service.stopService(self)
     if self.filename != '-':
         signal.signal(signal.SIGUSR1, self.__previous_signal_handler)
         del self.__previous_signal_handler
         self.observer.stop()
         self.observer = None
         self.logfile.close()
         self.logfile = None
     else:
         self.observer.stop()
         self.observer = None
         # Don't close stdout.
         self.logfile = None
Exemple #42
0
    def stopService(self):
        """
        Stop reading on the inherited port.

        @return: a Deferred which fires after the last outstanding request is
            complete.
        """
        Service.stopService(self)
        # XXX stopping should really be destructive, because otherwise we will
        # always leak a file descriptor; i.e. this shouldn't be restartable.
        self.reportingFactory.inheritedPort.stopReading()

        # Let any outstanding requests finish
        return self.reportingFactory.allConnectionsClosed()
Exemple #43
0
    def stopService(self):
        """
        Stop reading on the inherited port.

        @return: a Deferred which fires after the last outstanding request is
            complete.
        """
        Service.stopService(self)
        # XXX stopping should really be destructive, because otherwise we will
        # always leak a file descriptor; i.e. this shouldn't be restartable.
        self.reportingFactory.inheritedPort.stopReading()

        # Let any outstanding requests finish
        return self.reportingFactory.allConnectionsClosed()
Exemple #44
0
 def stopService(self):
     Service.stopService(self)
     if self.filename != '-':
         signal.signal(signal.SIGUSR1, self.__previous_signal_handler)
         del self.__previous_signal_handler
         self.observer.stop()
         self.observer = None
         self.logfile.close()
         self.logfile = None
     else:
         self.observer.stop()
         self.observer = None
         # Don't close stdout.
         self.logfile = None
Exemple #45
0
 def stopService(self):
     """Stop All AppManager Services"""
     for x in ['allapps', 'applist']:
         if x in drone.builtins:
             del drone.builtins[x]
     Event('instance-started').unsubscribe(self.reset_tracking)
     for manager in AppManager.objects:
         if manager.running:
             mesg = 'Stopping Application Manager'
             logWithContext(type=manager.name, route=SERVICENAME)(mesg)
             manager.stop()
             #plugins are stateless by design
             pluginFactory.delete_plugin(manager.model)
     if self._task.running: self._task.stop()
     Service.stopService(self)
Exemple #46
0
 def stopService(self):
     """Stop All AppManager Services"""
     for x in ['allapps', 'applist']:
         if x in drone.builtins:
             del drone.builtins[x]
     Event('instance-started').unsubscribe(self.reset_tracking)
     for manager in AppManager.objects:
         if manager.running:
             mesg = 'Stopping Application Manager'
             logWithContext(type=manager.name,route=SERVICENAME)(mesg)
             manager.stop()
             #plugins are stateless by design
             pluginFactory.delete_plugin(manager.model)
     if self._task.running: self._task.stop()
     Service.stopService(self)
Exemple #47
0
 def stopService(self):
     """
     Called when the plugin is stopped.  If a plugin needs to perform any
     shutdown task, they should override this method (be sure to chain up
     to the parent method) and perform them here.
     """
     return Service.stopService(self)
Exemple #48
0
 def stopService(self):
     """
     Called when the plugin is stopped.  If a plugin needs to perform any
     shutdown task, they should override this method (be sure to chain up
     to the parent method) and perform them here.
     """
     return Service.stopService(self)
Exemple #49
0
 def stopService(self):
     if self._delayedCall:
         self._delayedCall.cancel()
         self._delayedCall = None
         return
     self._looper.stop()
     self._loopFinished.addCallback(lambda _: Service.stopService(self))
     return self._loopFinished
Exemple #50
0
 def stopService(self):
     if self._delayedCall:
         self._delayedCall.cancel()
         self._delayedCall = None
         return
     self._looper.stop()
     self._loopFinished.addCallback(lambda _: Service.stopService(self))
     return self._loopFinished
Exemple #51
0
    def stopService(self):
        Service.stopService(self)
        self.ready = False
        for d in list(self._waiting):
            d.cancel()
        self._waiting = []

        def stop_timer(ignored):
            if not self._timer_service:
                return
            return self._timer_service.stopService()

        def cleanup(ignored):
            self._timer_service = None

        return (self._client.stop().addBoth(tap(stop_timer)).addBoth(
            tap(cleanup)))
 def stopService(self):
     if self.capture_logs:
         globalLogPublisher.removeObserver(self.twisted_observer)
         self.stdlib_cleanup()
     if self.task is not None:
         self.task.finish()
     for dest in self.destinations:
         remove_destination(dest)
     return Service.stopService(self)
Exemple #53
0
    def stopService(self):
        def exit(result):
            log.info("Stopping daemon...")
            if not reactor._stopped:
                reactor.stop()

        if self.running:
            Service.stopService(self)

            # Stop receiving cluster messages
            self._messagePort.stopListening()
            self.s_rpc.stopService().addErrback(log.err)

            # Cleanly leave cluster
            d = self.leaveCluster()
            d.addErrback(log.err)
            d.addBoth(exit)  # Even if there are errors
            return d
        else:
            return defer.succeed(None)