def startService(self): ## this implementation of startService overrides the original if self.running: return Service.startService(self) pingFunc, args, kwargs = self.call def pingFail(failure): failure.trap(defer.TimeoutError) #print 'Call to %s timed out. Calling onTimeout and stopping service.' % (pingFunc.__name__,) self.onTimeout() self.stopService() def sendPing(): self.ping = defer.Deferred() ## the pingFunc is assumed to be a syncronous function that ## sends the request along to the client and returns immediately. ## TODO: maybe assume that this returns a deferred that is fired when ## the response is received? pingFunc(*args, **kwargs) self.ping.addErrback(pingFail) self.ping.setTimeout( self.step - 1) # timeout if no response before next iteration return self.ping ## LoopingCall will reschedule as soon as this fires self._loop = LoopingCall(sendPing) self._loop.start(self.step, now=self.now).addErrback(self._failed)
def startService(self): """ Make sure that the necessary properties are set on the root Flocker zfs storage pool. """ Service.startService(self) # These next things are logically part of the storage pool creation # process. Since Flocker itself doesn't yet have any involvement with # that process, it's difficult to find a better time/place to set these # properties than here - ie, "every time we're about to interact with # the storage pool". In the future it would be better if we could do # these things one-off - sometime around when the pool is created or # when Flocker is first installed, for example. Then we could get rid # of these operations from this method (which eliminates the motivation # for StoragePool being an IService implementation). # https://clusterhq.atlassian.net/browse/FLOC-635 # Set the root dataset to be read only; IService.startService # doesn't support Deferred results, and in any case startup can be # synchronous with no ill effects. _sync_command_error_squashed( [b"zfs", b"set", b"readonly=on", self._name], self.logger) # If the root dataset is read-only then it's not possible to create # mountpoints in it for its child datasets. Avoid mounting it to avoid # this problem. This should be fine since we don't ever intend to put # any actual data into the root dataset. _sync_command_error_squashed( [b"zfs", b"set", b"canmount=off", self._name], self.logger)
def startService(self): Service.startService(self) self.configuration.load() self.connectionRegistry = \ ConnectionRegistry( self.createConfiguredDeviceMap()) self.timer.start(self.updateInterval).addErrback(log.err) self.statusIcon.show()
def startService(self): self.storage_reload_task.start(60, False) self.aggregation_reload_task.start(60, False) reactor.addSystemEventTrigger('before', 'shutdown', shutdownModifyUpdateSpeed) reactor.callInThread(writeForever) Service.startService(self)
def startService(self): """ Start the service by calling stored function """ Service.startService(self) if self._start: return self._start()
def startService(self): """ Called when the plugin is started. If a plugin needs to perform any startup tasks, they should override this method (be sure to chain up to the parent method) and perform them here. """ Service.startService(self)
def startService(self): ## this implementation of startService overrides the original if self.running: return Service.startService(self) pingFunc, args, kwargs = self.call def pingFail(failure): failure.trap(defer.TimeoutError) #print 'Call to %s timed out. Calling onTimeout and stopping service.' % (pingFunc.__name__,) self.onTimeout() self.stopService() def sendPing(): self.ping = defer.Deferred() ## the pingFunc is assumed to be a syncronous function that ## sends the request along to the client and returns immediately. ## TODO: maybe assume that this returns a deferred that is fired when ## the response is received? pingFunc(*args, **kwargs) self.ping.addErrback(pingFail) self.ping.setTimeout(self.step - 1) # timeout if no response before next iteration return self.ping ## LoopingCall will reschedule as soon as this fires self._loop = LoopingCall(sendPing) self._loop.start(self.step, now=self.now).addErrback(self._failed)
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()
def startService(self): self._database = self._create_database() try: cfg_collection = ConfigCollection( self._database.collection('configs')) dev_collection = DeviceCollection( self._database.collection('devices')) if self._config['database']['ensure_common_indexes']: logger.debug('Ensuring index existence on collections') try: dev_collection.ensure_index(u'mac') dev_collection.ensure_index(u'ip') dev_collection.ensure_index(u'sn') except AttributeError as e: logger.warning( 'This type of database doesn\'t seem to support index: %s', e) self.app = ProvisioningApplication(cfg_collection, dev_collection, self._config) except Exception: try: raise finally: self._close_database() else: Service.startService(self)
def startService(self): log.info("starting DBase Service") yield self.schema() self.startTasks() # Remainder Service initialization Service.startService(self) log.info("Database operational.")
def startService(self): Service.startService(self) if self.__ws_port_obj is not None: raise Exception('Already started') self.__http_port_obj = yield self.__http_endpoint.listen(self.__site) self.__ws_port_obj = yield self.__ws_endpoint.listen( self.__ws_protocol)
def startService(self): Service.startService(self) log.info("Starting RPC service...") self.cleanSocket(None) self._localPort=reactor.listenUNIX(core.cfg['UNIX_PORT'], pb.PBServerFactory(LocalRPC(self._master))) self._remotePort=reactor.listenTCP(core.cfg['TCP_PORT'], pb.PBServerFactory(RemoteRPC(self._master)))
def startService(self): app = self._prov_service.app dhcp_request_processing_service = self._dhcp_process_service.dhcp_request_processing_service if self._config['general.rest_authentication']: credentials = (self._config['general.rest_username'], self._config['general.rest_password']) server_resource = new_restricted_server_resource(app, dhcp_request_processing_service, credentials) logger.info('Authentication is required for REST API') else: server_resource = new_server_resource(app, dhcp_request_processing_service) logger.warning('No authentication is required for REST API') root_resource = Resource() root_resource.putChild('provd', server_resource) rest_site = Site(root_resource) port = self._config['general.rest_port'] interface = self._config['general.rest_ip'] if interface == '*': interface = '' logger.info('Binding HTTP REST API service to "%s:%s"', interface, port) if self._config['general.rest_ssl']: logger.info('SSL enabled for REST API') context_factory = ssl.DefaultOpenSSLContextFactory(self._config['general.rest_ssl_keyfile'], self._config['general.rest_ssl_certfile']) self._tcp_server = internet.SSLServer(port, rest_site, context_factory, interface=interface) else: self._tcp_server = internet.TCPServer(port, rest_site, interface=interface) self._tcp_server.startService() Service.startService(self)
def startService(self): if self.loop != -1 or self._state == 'started': msg(self.name, 'start fail - already started', system='-') # Already started return # State self._state = 'starting' # Show info msg(self.name, 'start', system='-') # Cancel stop if self._stopCall: self._stopCall.cancel() self._stopCall = None # Call stop self._stopDeferred.callback(0) self._stopDeferred = None Service.startService(self) self.loop = 0 self._state = 'started' # Start for name, (run, interval) in self._runs.iteritems(): run.start(interval, now=False) # Show info msg(self.name, 'started', system='-')
def startService(self, _reactor=reactor): assert not self._already_started, "can start the PullRequest service once" self._already_started = True Service.startService(self) print 'PullRequest service starting: %s ...' % self.context.name d = defer.Deferred() _reactor.callWhenRunning(d.callback, None) yield d try: from .serviceloops import PullRequestsWatchLoop, SchedulerLoop self.watchLoop = PullRequestsWatchLoop(self.context) yield self.watchLoop.start() self.schedulerLoop = SchedulerLoop(self.context) yield self.schedulerLoop.start(); except: f = failure.Failure() log.err(f, 'while starting PullRequest service: %s' % self.context.name) _reactor.stop() log.msg('PullRequest service is running: %s' % self.context.name)
def startService(self): ''' Starts Stats service ''' log.info("starting Stats Service: Window Size= {w} samples", w=self.options['size']) Service.startService(self) reactor.callLater(0, self.accumulate) self.nsamples = 0 self.started = True self.queue = { 'violet' : deque([], self.qsize), 'blue' : deque([], self.qsize), 'green' : deque([], self.qsize), 'yellow' : deque([], self.qsize), 'orange' : deque([], self.qsize), 'red' : deque([], self.qsize), 'raw_violet' : deque([], self.qsize), 'raw_blue' : deque([], self.qsize), 'raw_green' : deque([], self.qsize), 'raw_yellow' : deque([], self.qsize), 'raw_orange' : deque([], self.qsize), 'raw_red' : deque([], self.qsize), } log.info("photodiode current (A) = {current}", current= self.photodiode)
def startService(self): Service.startService(self) if self.__ws_port_obj is not None: raise Exception('Already started') self.__ws_port_obj = strports.listen(self.__ws_port, self.__ws_protocol) self.__http_port_obj = strports.listen(self.__http_port, self.__site)
def startService(self): Service.startService(self) # Now we're ready to build the command lines and actualy add the # processes to procmon. This step must be done prior to setting # active to 1 for processObject, env in self.processObjects: name = processObject.getName() self.addProcess( name, processObject.getCommandLine(), env=env ) self._extraFDs[name] = processObject.getFileDescriptors() self.active = 1 delay = 0 if config.MultiProcess.StaggeredStartup.Enabled: delay_interval = config.MultiProcess.StaggeredStartup.Interval else: delay_interval = 0 for name in self.processes.keys(): if name.startswith("caldav"): when = delay delay += delay_interval else: when = 0 callLater(when, self.startProcess, name) self.consistency = callLater( self.consistencyDelay, self._checkConsistency )
def startService(self): Service.startService(self) # Services can get started before the reactor has started. This # complicates things. Get rid of all that complexity but not running # any interesting application code until the reactor has actually # started. self.reactor.callWhenRunning(self._run_and_stop)
def startService(self): Service.startService(self) bindDeferred = self.client.connectAndBind() bindDeferred.addErrback(self.handleStartError) smpp = yield bindDeferred smpp.getDisconnectedDeferred().chainDeferred(self.stopDeferred) defer.returnValue(smpp)
def startService(self): Service.startService(self) self._registered = False self._timer_service = TimerService( self.check_interval.total_seconds(), self._check_certs) self._timer_service.clock = self._clock self._timer_service.startService()
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()
def startService(self): """ Start the writer thread. """ Service.startService(self) self._thread = threading.Thread(target=self._writer) self._thread.start() addDestination(self)
def startService(self): """ Start HiiTrack. """ self.logloop.start(60*5, False) Service.startService(self) cassandra.CLIENT.startService() self.listener = reactor.listenTCP(self.port, Site(self.dispatcher))
def stopService(self): "Stop reading from the stream." ret = None if self.running and self._streamDone is not None: self._streamDone.cancel() ret = self._streamDone Service.startService(self) return ret
def startService(self): version = get_version() log.msg( "Duo Security Authentication Proxy {version} - Init Complete", version=version, ) log.ready() Service.startService(self)
def startService(self): """ Start ThreadWrapper :return: """ Service.startService(self) from threading import Thread self.thread = Thread(target=self._run, name=self.name)
def startService(self): Service.startService(self) try: self.startServiceReal() except Exception: for l in traceback.format_exc().split("\n"): self.console(l, kind='error') self.shutdown()
def startService(self): Service.startService(self) if self.clock is None: from twisted.internet import reactor self.clock = reactor self._connect()
def startService(self): yield maybeDeferred(self.eventloop.prepare) Service.startService(self) yield self._set_globals() yield DeferredList([ maybeDeferred(service.startService) for service in self ])
def startService(self): app = self._prov_service.app process_service = self._process_service.request_processing tftp_process_service = ident.TFTPRequestProcessingService( process_service, app.pg_mgr) self._tftp_protocol.set_tftp_request_processing_service( tftp_process_service) Service.startService(self)
def startService(self): Service.startService(self) # Print welcome message log.info("Starting cxmd version", meta.version) self._messagePort=reactor.listenUDP(core.cfg['UDP_PORT'], UDPListener(self.dispatchMessage)) reactor.callLater(2, self.joinCluster)
def startService(self): """Start Janitizer Service""" self.GARBAGE_CHECK = task.LoopingCall(self.garbageCheck) self.ELDERLY_CHECK = task.LoopingCall(self.clean_elderly) #start the service Service.startService(self) self.GARBAGE_CHECK.start(self.minute * 20) self.ELDERLY_CHECK.start(self.minute)
def startService(self): """ """ Service.startService(self) from twisted.internet import reactor logger.debug("performing initial registration") for uri,system in self.known.items(): self.register_system(uri, system)
def startService(self): # Pre: hasattr(self._prov_service, 'app') self.request_processing = provd.devices.ident.RequestProcessingService(self._prov_service.app) request_config_dir = self._config['general.request_config_dir'] for name in ['info_extractor', 'retriever', 'updater', 'router']: setattr(self.request_processing, 'dev_' + name, self._create_processor(request_config_dir, name, self._config['general.' + name])) Service.startService(self)
def startService(self): if 'signal' in globals().keys(): log.debug("Installing SIG_IGN for SIGHUP") signal.signal(signal.SIGHUP, signal.SIG_IGN) Service.startService(self) for factory in self.client_factories.values(): if not factory.started: factory.startConnecting()
def startService(self): try: with open('tokens.msgpack', 'rb') as f: self.tokens = msgpack_helpers.load(f.read()) except (IOError, OSError, msgpack.UnpackException, msgpack.UnpackValueError): pass self.expired_cleaner = LoopingCall(self._clean_expired) self.expired_cleaner.start(self.clean_period) Service.startService(self)
def startService(self): # Pre: hasattr(self._prov_service, 'app') dev_info_extractor = self._create_processor('info_extractor') dev_retriever = self._create_processor('retriever') dev_updater = self._create_processor('updater') self.request_processing = ident.RequestProcessingService( self._prov_service.app, dev_info_extractor, dev_retriever, dev_updater) Service.startService(self)
def startService(self): if 'signal' in globals().keys(): log.msg("Installing SIG_IGN for SIGHUP") signal.signal(signal.SIGHUP, signal.SIG_IGN) self.storage_reload_task.start(60, False) self.aggregation_reload_task.start(60, False) reactor.addSystemEventTrigger('before', 'shutdown', shutdownModifyUpdateSpeed) reactor.callInThread(writeForever) Service.startService(self)
def startService(self): self._task = task.LoopingCall(self.write) # delay first journaling reactor.callLater(config.JOURNAL_FREQUENCY, self._task.start, config.JOURNAL_FREQUENCY) # minimize the chances of losing started instances Event("journal-error").subscribe(self._journal_failure) Event("instance-started").subscribe(self.write) Event("signal").subscribe(self.write) Service.startService(self)
def startService(self): ''' Starts Stats service ''' log.info("starting Storage Service") Service.startService(self) path = resource_filename(__name__, 'data/QE_photodiode.csv') self.loadQE(path) log.debug("QE data is {qe}", qe=self.qe_data)
def startService(self): # announce to matchmaker that server is activae # try: # res = requests.post(HUB+"/api/v1.0/register", json={"port": self.port, "id": self.node_id}, timeout=10) # except requests.exceptions.RequestException as e: # log.error("Could not notify hub due to request error: {}".format(e)) # else: # log.info("Service start, notified hub with code {}".format(res.status_code)) Service.startService(self)
def startService(self): Service.startService(self) log.info("Starting RPC service...") self.cleanSocket(None) self._localPort = reactor.listenUNIX( core.cfg['UNIX_PORT'], pb.PBServerFactory(LocalRPC(self._master))) self._remotePort = reactor.listenTCP( core.cfg['TCP_PORT'], pb.PBServerFactory(RemoteRPC(self._master)))
def startService(self): Service.startService(self) # Print welcome message log.info("Starting cxmd version", meta.version) self._messagePort = reactor.listenUDP( core.cfg['UDP_PORT'], UDPListener(self.dispatchMessage)) reactor.callLater(2, self.joinCluster)
def startService(self): """Initiate execution.""" Service.startService(self) ds = [] for svc in self: log.debug("{0} starting service: {1}".format(self, svc)) d = maybeDeferred(svc.startService) ds.append(d) yield gatherResults(ds) yield self._execute()
def startService(self): Service.startService(self) if self.statsfile != '': self._loadStats() self._syncstats = task.LoopingCall(self._saveStats) self._syncstats.start(self.syncinterval, False) logger.debug("logging statistics to %s every %i seconds" % (self.statsfile,self.syncinterval)) else: logger.debug("statistics logging is disabled") self._syncstats = None
def startService(self): # self.storage_reload_task.start(60, False) # self.aggregation_reload_task.start(60, False) startPublisher('localhost', 5672, 'guest', 'guest', vhost='/', exchange_name='graphite', verbose=True) reactor.run() # reactor.callInThread(writeForever) Service.startService(self)
def startService(self): """ Start reading on the inherited port. """ Service.startService(self) self.reportingFactory = ReportingHTTPFactory(self.site, vary=True) inheritedPort = self.reportingFactory.inheritedPort = InheritedPort( self.fd, self.createTransport, self.reportingFactory) inheritedPort.startReading() inheritedPort.reportStatus("0")
def startService(self): """ Starts a loop to fetch mail. """ Service.startService(self) if self._loop is None: self._loop = LoopingCall(self.fetch) return self._loop.start(self._check_period) else: logger.warning("Tried to start an already running fetching loop.")