当前位置: 首页>>代码示例>>Python>>正文


Python Service.startService方法代码示例

本文整理汇总了Python中twisted.application.service.Service.startService方法的典型用法代码示例。如果您正苦于以下问题:Python Service.startService方法的具体用法?Python Service.startService怎么用?Python Service.startService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.application.service.Service的用法示例。


在下文中一共展示了Service.startService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
    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)
开发者ID:Waynelemars,项目名称:flocker,代码行数:32,代码来源:zfs.py

示例2: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
 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()
开发者ID:yaniv-aknin,项目名称:pay4bytes,代码行数:9,代码来源:core.py

示例3: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
    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)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:31,代码来源:main.py

示例4: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
	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='-')
开发者ID:p0is0n,项目名称:mail-services,代码行数:35,代码来源:garbage.py

示例5: main

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
    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()
开发者ID:sysuwbs,项目名称:flocker,代码行数:32,代码来源:script.py

示例6: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
 def startService(self):
     log.info("starting DBase Service")
     yield self.schema()
     self.startTasks()
     # Remainder Service initialization
     Service.startService(self)
     log.info("Database operational.")
开发者ID:sergiopasra,项目名称:tessdb,代码行数:9,代码来源:dbservice.py

示例7: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
    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
        )
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:37,代码来源:caldav.py

示例8: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
    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)
开发者ID:alalek,项目名称:common-pullrequest-plugin,代码行数:28,代码来源:service.py

示例9: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
 def startService(self):
     """
     Start the service by calling stored function
     """
     Service.startService(self)
     if self._start:
         return self._start()
开发者ID:meker12,项目名称:otter,代码行数:9,代码来源:api.py

示例10: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
 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)
开发者ID:DSDev-NickHogle,项目名称:terane,代码行数:9,代码来源:plugins.py

示例11: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
   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)
开发者ID:istobran,项目名称:eaEmu,代码行数:30,代码来源:timer.py

示例12: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
	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)))
开发者ID:nagius,项目名称:cxm,代码行数:9,代码来源:rpc.py

示例13: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
 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()
开发者ID:mithrandi,项目名称:txacme,代码行数:9,代码来源:service.py

示例14: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
 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))
开发者ID:hiidef,项目名称:hiitrack-api,代码行数:10,代码来源:http.py

示例15: startService

# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import startService [as 别名]
    def startService(self):
        Service.startService(self)

        if self.clock is None:
            from twisted.internet import reactor
            self.clock = reactor

        self._connect()
开发者ID:froztbyte,项目名称:txTwitter,代码行数:10,代码来源:streamservice.py


注:本文中的twisted.application.service.Service.startService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。