本文整理汇总了Python中twisted.application.service.MultiService.startService方法的典型用法代码示例。如果您正苦于以下问题:Python MultiService.startService方法的具体用法?Python MultiService.startService怎么用?Python MultiService.startService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.application.service.MultiService
的用法示例。
在下文中一共展示了MultiService.startService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
global configurations, expectations
print "Loaded configurations: " + str(configurations)
reload(sys)
sys.setdefaultencoding('utf8')
Expectations.display(expectations)
MultiService.startService(self)
示例2: TestTCPRedirect
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
class TestTCPRedirect(TestUDPRedirect):
def setUp(self):
self.service = MultiService()
self.received = []
class Collect(LineReceiver):
def lineReceived(cself, data):
self.got_data(data)
class CollectFactory(Factory):
def buildProtocol(self, addr):
return Collect()
self.port = reactor.listenTCP(0, CollectFactory())
self.processor = TestMessageProcessor()
self.router = Router(self.processor,
r"any => redirect_tcp 127.0.0.1 %s" %
(self.port.getHost().port,),
service=self.service)
self.service.startService()
return self.router.ready
示例3: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
# create WebSocket echo service and make it a child of our app service
svc = EchoService(self.port)
svc.setName("EchoService")
svc.setServiceParent(self)
MultiService.startService(self)
示例4: setUp
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
class TestServicesBase:
run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)
def setUp(self):
super(TestServicesBase, self).setUp()
self.observers = theLogPublisher.observers[:]
self.services = MultiService()
self.services.privilegedStartService()
self.services.startService()
def tearDown(self):
super(TestServicesBase, self).tearDown()
d = self.services.stopService()
# The log file must be read in right after services have stopped,
# before the temporary directory where the log lives is removed.
d.addBoth(lambda ignore: self.addDetailFromLog())
d.addBoth(lambda ignore: self.assertNoObserversLeftBehind())
return d
def addDetailFromLog(self):
content = content_from_file(self.log_filename, buffer_now=True)
self.addDetail("log", content)
def assertNoObserversLeftBehind(self):
self.assertEqual(self.observers, theLogPublisher.observers)
示例5: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
MultiService.startService(self)
clusterDir = self.dataStoreDirectory.child("cluster")
workingDir = self.dataStoreDirectory.child("working")
env = self.env = os.environ.copy()
env.update(PGDATA=clusterDir.path,
PGHOST=self.socketDir.path)
initdb = which("initdb")[0]
if not self.socketDir.isdir():
self.socketDir.createDirectory()
if self.uid and self.gid:
os.chown(self.socketDir.path, self.uid, self.gid)
if self.dataStoreDirectory.isdir():
self.startDatabase()
else:
self.dataStoreDirectory.createDirectory()
workingDir.createDirectory()
if self.uid and self.gid:
os.chown(self.dataStoreDirectory.path, self.uid, self.gid)
os.chown(workingDir.path, self.uid, self.gid)
dbInited = Deferred()
reactor.spawnProcess(
CapturingProcessProtocol(dbInited, None),
initdb, [initdb], env, workingDir.path,
uid=self.uid, gid=self.gid,
)
def doCreate(result):
self.startDatabase()
dbInited.addCallback(doCreate)
示例6: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
# Set up configuration manager
self.config = self._build_config_manager()
yield self.config.prepare()
yield self.prepareService()
MultiService.startService(self)
示例7: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
log.msg('...Booting...', system="Bouser")
self.reload_config()
log.callWithContext({"system": "Bootstrap"}, boot.send, self)
log.callWithContext({"system": "Checking Dependencies"}, check_deps.send, self)
if self.fail:
raise RuntimeError('Not all dependencies satisfied')
else:
MultiService.startService(self)
示例8: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
MultiService.startService(self)
self.activateDelayedShutdown()
clusterDir = self.dataStoreDirectory.child(self.clusterName)
env = self.env = os.environ.copy()
env.update(PGDATA=clusterDir.path,
PGHOST=self.host,
PGUSER=self.spawnedDBUser)
if self.socketDir:
if not self.socketDir.isdir():
log.info("Creating {dir}", dir=self.socketDir.path.decode("utf-8"))
self.socketDir.createDirectory()
if self.uid and self.gid:
os.chown(self.socketDir.path, self.uid, self.gid)
os.chmod(self.socketDir.path, 0770)
if not self.dataStoreDirectory.isdir():
log.info("Creating {dir}", dir=self.dataStoreDirectory.path.decode("utf-8"))
self.dataStoreDirectory.createDirectory()
if not self.workingDir.isdir():
log.info("Creating {dir}", dir=self.workingDir.path.decode("utf-8"))
self.workingDir.createDirectory()
if self.uid and self.gid:
os.chown(self.dataStoreDirectory.path, self.uid, self.gid)
os.chown(self.workingDir.path, self.uid, self.gid)
if not clusterDir.isdir():
# No cluster directory, run initdb
log.info("Running initdb for {dir}", dir=clusterDir.path.decode("utf-8"))
dbInited = Deferred()
self.reactor.spawnProcess(
CapturingProcessProtocol(dbInited, None),
self._initdb,
[self._initdb, "-E", "UTF8", "-U", self.spawnedDBUser],
env=env, path=self.workingDir.path,
uid=self.uid, gid=self.gid,
)
def doCreate(result):
if result.find("FATAL:") != -1:
log.error(result)
raise InternalDataStoreError(
"Unable to initialize postgres database: {}"
.format(result)
)
self.startDatabase()
dbInited.addCallback(doCreate)
else:
log.info("Cluster already exists at {dir}", dir=clusterDir.path.decode("utf-8"))
self.startDatabase()
示例9: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
MultiService.startService(self)
self._listener = reactor.listenTCP(CoreHttpConfig.HTTP_PORT, channel.HTTPFactory(self._site))
self.log_info("started core service")
self.upnp_service = UPNPService()
# load enabled services
try:
for name in conf.get("CORE_ENABLED_PLUGINS", []):
self.enablePlugin(name)
self.log_debug("started all enabled services")
except Exception, e:
raise e
示例10: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
if not self._path.exists():
self._path.makedirs()
self._config_path = self._path.child(b"current_configuration.v1.json")
if self._config_path.exists():
self._deployment = wire_decode(
self._config_path.getContent())
else:
self._deployment = Deployment(nodes=frozenset())
self._sync_save(self._deployment)
MultiService.startService(self)
_LOG_STARTUP(configuration=self.get()).write(self.logger)
示例11: start_site
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def start_site(reactor, site, secure_ports, insecure_ports, redirect_to_port):
parent = MultiService()
for secure in secure_ports:
StreamServerEndpointService(secure, site).setServiceParent(parent)
if insecure_ports:
redirector = make_redirector_site(redirect_to_port)
for insecure in insecure_ports:
StreamServerEndpointService(insecure, redirector).setServiceParent(parent)
parent.privilegedStartService()
parent.startService()
示例12: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
print "RconManager.startService..."
self.mongo = self.getRootService().getMongo()
servers = yield self.mongo.servers.find()
for server in servers:
print "Starting server:",server
factory = getClientRconFactory(server, self)
client = TCPClient(server["ip"], int(server["port"]), factory)
client.setServiceParent(self)
server["factory"] = factory
self.servers[server["tag"]] = server
print self.servers
MultiService.startService(self)
示例13: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
MultiService.startService(self)
staticPath = FilePath(__file__).sibling("static")
root = NoListDirFile(staticPath.path)
root.putChild('api', SockJSResource(
Factory.forProtocol(DaneDoctorProtocol))
)
webService = StreamServerEndpointService(
serverFromString(self._reactor, "tcp:8080"),
Site(root)
)
webService.setServiceParent(self)
示例14: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
MultiService.startService(self)
if not self.dataStoreDirectory.isdir():
log.info("Creating {dir}", dir=self.dataStoreDirectory.path)
self.dataStoreDirectory.createDirectory()
if not self.workingDir.isdir():
log.info("Creating {dir}", dir=self.workingDir.path)
self.workingDir.createDirectory()
self.subServiceFactory(
self.produceConnection, self
).setServiceParent(self)
示例15: startService
# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import startService [as 别名]
def startService(self):
MultiService.startService(self)
self.activateDelayedShutdown()
clusterDir = self.dataStoreDirectory.child(self.clusterName)
env = self.env = os.environ.copy()
env.update(PGDATA=clusterDir.path,
PGHOST=self.host,
PGUSER=self.spawnedDBUser)
initdb = self.initdb()
if self.socketDir:
if not self.socketDir.isdir():
self.socketDir.createDirectory()
if self.uid and self.gid:
os.chown(self.socketDir.path, self.uid, self.gid)
os.chmod(self.socketDir.path, 0770)
if self.dataStoreDirectory.isdir():
self.startDatabase()
else:
self.dataStoreDirectory.createDirectory()
if not self.workingDir.isdir():
self.workingDir.createDirectory()
if self.uid and self.gid:
os.chown(self.dataStoreDirectory.path, self.uid, self.gid)
os.chown(self.workingDir.path, self.uid, self.gid)
dbInited = Deferred()
self.reactor.spawnProcess(
CapturingProcessProtocol(dbInited, None),
initdb, [initdb, "-E", "UTF8", "-U", self.spawnedDBUser],
env=env, path=self.workingDir.path,
uid=self.uid, gid=self.gid,
)
def doCreate(result):
if result.find("FATAL:") != -1:
log.error(result)
raise RuntimeError(
"Unable to initialize postgres database: {}"
.format(result)
)
self.startDatabase()
dbInited.addCallback(doCreate)