當前位置: 首頁>>代碼示例>>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方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _create_volume_service

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def _create_volume_service(cls, stderr, reactor, options):
        """
        Create a ``VolumeService`` for the given arguments.

        :return: The started ``VolumeService``.
        """
        pool = StoragePool(reactor, options["pool"],
                           FilePath(options["mountpoint"]))
        service = cls._service_factory(
            config_path=options["config"], pool=pool, reactor=reactor)
        try:
            service.startService()
        except CreateConfigurationError as e:
            stderr.write(
                b"Writing config file %s failed: %s\n" % (
                    options["config"].path, e)
            )
            raise SystemExit(1)
        return service 
開發者ID:ClusterHQ,項目名稱:flocker,代碼行數:21,代碼來源:service.py

示例2: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        """
        Start a loop to fetch mail.
        """
        if self.running:
            return

        Service.startService(self)
        if self._loop is None:
            self._loop = LoopingCall(self.fetch)
        self._loop.start(self._check_period) 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:13,代碼來源:service.py

示例3: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        Service.startService(self)
        parent = self._config_path.parent()
        try:
            if not parent.exists():
                parent.makedirs()
            if not self._config_path.exists():
                uuid = unicode(uuid4())
                self._config_path.setContent(json.dumps({u"uuid": uuid,
                                                         u"version": 1}))
        except OSError as e:
            raise CreateConfigurationError(e.args[1])
        config = json.loads(self._config_path.getContent())
        self.node_id = config[u"uuid"]
        self.pool.startService() 
開發者ID:ClusterHQ,項目名稱:flocker,代碼行數:17,代碼來源:service.py

示例4: 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:ClusterHQ,項目名稱:flocker,代碼行數:32,代碼來源:zfs.py

示例5: 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:twisted,項目名稱:txacme,代碼行數:9,代碼來源:service.py

示例6: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        if self.metric_interval > 0:
            self.record_task.start(self.metric_interval, False)
        Service.startService(self) 
開發者ID:douban,項目名稱:Kenshin,代碼行數:6,代碼來源:instrumentation.py

示例7: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        reactor.callInThread(writeForever)
        Service.startService(self) 
開發者ID:douban,項目名稱:Kenshin,代碼行數:5,代碼來源:writer.py

示例8: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        """
        Start the writer thread.
        """
        Service.startService(self)
        self._thread = threading.Thread(target=self._writer)
        self._thread.start()
        addDestination(self) 
開發者ID:itamarst,項目名稱:eliot,代碼行數:10,代碼來源:logwriter.py

示例9: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
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") 
開發者ID:apple,項目名稱:ccs-calendarserver,代碼行數:13,代碼來源:metafd.py

示例10: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        Service.startService(self)
        logging.info("%s started with config %s" % (
            self.service_name.capitalize(), self.config.get_config_filename())) 
開發者ID:CanonicalLtd,項目名稱:landscape-client,代碼行數:6,代碼來源:service.py

示例11: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        yield maybeDeferred(self.eventloop.prepare)
        Service.startService(self)
        yield self._set_globals()
        yield DeferredList(
            [maybeDeferred(service.startService) for service in self]
        ) 
開發者ID:maas,項目名稱:maas,代碼行數:9,代碼來源:eventloop.py

示例12: startMultiService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startMultiService(self, result):
        """Start the multi service."""
        self.services.startService() 
開發者ID:maas,項目名稱:maas,代碼行數:5,代碼來源:eventloop.py

示例13: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
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) 
開發者ID:LeastAuthority,項目名稱:kubetop,代碼行數:9,代碼來源:_runonce.py

示例14: startService

# 需要導入模塊: from twisted.application.service import Service [as 別名]
# 或者: from twisted.application.service.Service import startService [as 別名]
def startService(self):
        Service.startService(self)
        bootstrap_list.bootstrap(data_path=self._config.data_path,
                                 log_dir=self._config.log_dir)
        if self._config.clones > 0:

            # Let clones open an appropriate number of fds
            setrlimit(RLIMIT_NOFILE, (self._config.clones * 100,
                                      self._config.clones * 200))

            # Increase the timeout of AMP's MethodCalls.
            # XXX: we should find a better way to expose this knot, and
            # not set it globally on the class
            from landscape.lib.amp import MethodCallSender
            MethodCallSender.timeout = 300

            # Create clones log and data directories
            for i in range(self._config.clones):
                suffix = "-clone-%d" % i
                bootstrap_list.bootstrap(
                    data_path=self._config.data_path + suffix,
                    log_dir=self._config.log_dir + suffix)

        result = succeed(None)
        result.addCallback(lambda _: self.watchdog.check_running())

        def start_if_not_running(running_daemons):
            if running_daemons:
                error("ERROR: The following daemons are already running: %s"
                      % (", ".join(x.program for x in running_daemons)))
                self.exit_code = 1
                reactor.crash()  # so stopService isn't called.
                return
            self._daemonize()
            info("Watchdog watching for daemons.")
            return self.watchdog.start()

        def die(failure):
            log_failure(failure, "Unknown error occurred!")
            self.exit_code = 2
            reactor.crash()
        result.addCallback(start_if_not_running)
        result.addErrback(die)
        return result 
開發者ID:CanonicalLtd,項目名稱:landscape-client,代碼行數:46,代碼來源:watchdog.py


注:本文中的twisted.application.service.Service.startService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。