本文整理汇总了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
示例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)
示例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()
示例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)
示例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()
示例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)
示例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)
示例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)
示例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")
示例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()))
示例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]
)
示例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()
示例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)
示例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