• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python smprocess.SmProcess类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中servicemanager.smprocess.SmProcess的典型用法代码示例。如果您正苦于以下问题:Python SmProcess类的具体用法?Python SmProcess怎么用?Python SmProcess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: _start_from_sources

    def _start_from_sources(self):

        service_data = self.context.service_data(self.service_name)
        assets_path = self.context.application.workspace + service_data["location"]

        cmd_with_params = self.service_data["sources"]["cmd"]
        force_pushdir(assets_path)
        run_from_file = open("RUNNING_FROM", 'w')
        run_from_file.write(self.run_from)
        run_from_file.close()

        makedirs_if_not_exists("logs")
        seconds_remaining = SmPythonServiceStarter.PROCESS_STARTUP_TIMEOUT_SECONDS

        with open("logs/stdout.txt", "wb") as out, open("logs/stderr.txt", "wb") as err:
            subprocess.Popen(cmd_with_params, shell=False, env=os.environ.copy(), stdout=out, stderr=err, close_fds=True)

        while seconds_remaining > 0 and not len(SmProcess.processes_matching("grunt")) > 0:
            time.sleep(1)
            seconds_remaining -= 1
            if seconds_remaining < 10 or seconds_remaining % 5 == 0:
                self.log("Waiting for Assets service to start: %s second%s before timeout" % (
                    seconds_remaining, "s" if seconds_remaining > 1 else ""))
        if len(SmProcess.processes_matching("grunt")) == 1:
            process = SmProcess.processes_matching("grunt")
            for i, v in enumerate(process):
                    return v.pid
开发者ID:eamonnfaherty,项目名称:service-manager,代码行数:27,代码来源:smpythonservice.py


示例2: test_successful_play_from_jar_without_waiting_with_append_args

    def test_successful_play_from_jar_without_waiting_with_append_args(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        sm_application = SmApplication(config_dir_override)
        context = SmContext(sm_application, None, False, False)
        service_resolver = ServiceResolver(sm_application)

        context.kill_everything()
        time.sleep(5)

        response1 = actions.start_one(context, "FAKE_NEXUS", True, False, None, None, None)
        self.assertTrue(response1)
        self.assertIsNotNone(context.get_service("FAKE_NEXUS").status())
        time.sleep(5)

        servicetostart = ["PLAY_NEXUS_END_TO_END_TEST"]
        appendArgs = {"PLAY_NEXUS_END_TO_END_TEST": ["-DFoo=Bar"]}
        fatJar = True
        release = False
        proxy = None
        port = None
        seconds_to_wait = None

        try:
            actions.start_and_wait(service_resolver, context, servicetostart, fatJar, release, proxy, port, seconds_to_wait, appendArgs)
            time.sleep(5)
            service = SmPlayService(context, "PLAY_NEXUS_END_TO_END_TEST")
            processes = SmProcess.processes_matching(service.pattern)
            self.assertEqual(len(processes), 1)
            self.assertTrue("-DFoo=Bar" in processes[0].args)
        finally:
            context.kill_everything()
开发者ID:liquidarmour,项目名称:service-manager,代码行数:31,代码来源:tests.py


示例3: stop

    def stop(self):
        processes = SmProcess.processes_matching(self.pattern)

        for process in processes:
            kill_pid(self.context, process.ppid)
            kill_pid(self.context, process.pid)
            print "name: %s\tppid: %s\tpid: %s\tuptime: %s" % (self.service_name, process.ppid, process.pid, process.uptime)
开发者ID:eamonnfaherty,项目名称:service-manager,代码行数:7,代码来源:smexternalservice.py


示例4: test_play_with_append_args

    def test_play_with_append_args(self):
        config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
        context = SmContext(SmApplication(config_dir_override), None, False, False)
        context.kill_everything()

        # Start up fake nexus first
        response1 = actions.start_one(context, "FAKE_NEXUS", True, False, None, port=None)
        self.assertTrue(response1)
        self.assertIsNotNone(context.get_service("FAKE_NEXUS").status())
        time.sleep(5)

        server = smserverlogic.SmServer(SmApplication(config_dir_override, None))
        request = dict()
        request["testId"] = "foo"
        request["services"] = [
            {"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT", "appendArgs": ["-Dfoo=bar"]}
        ]
        smserverlogic.SmStartRequest(server, request, True, False).process_request()
        time.sleep(5)
        self.assertEqual(len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 1)
        service = SmPlayService(context, "PLAY_NEXUS_END_TO_END_TEST")
        processes = SmProcess.processes_matching(service.pattern)
        self.assertEqual(len(processes), 1)
        self.assertTrue("-Dfoo=bar" in processes[0].args)
        context.kill_everything()
        self.assertEqual(context.get_service("TEST_ONE").status(), [])
开发者ID:Jagordon,项目名称:service-manager,代码行数:26,代码来源:tests.py


示例5: is_started_on_default_port

    def is_started_on_default_port(self):
        processes = SmProcess.processes_matching(self.pattern)
        default_port_argument = "-D%s=%d" % (self.get_port_argument, self.default_port)

        for process in processes:
            if process.has_argument(default_port_argument):
                return True

        return False
开发者ID:vaughansharman,项目名称:service-manager,代码行数:9,代码来源:smjvmservice.py


示例6: status

    def status(self, all_processes=None):
        processes = SmProcess.processes_matching(self.pattern, all_processes)

        def _status_for_process(process):
            port = process.extract_integer_argument('-D%s=(\d*)' % self.get_port_argument(), self.default_port)
            test_id = process.extract_argument('-Dservice.manager.testId=([^ ]+)', "")
            run_from = process.extract_argument('-Dservice.manager.runFrom=([^ ]+)', "")
            features = process.extract_arguments('-Dfeature.([^ =]+)=true', "")
            healthcheck = SmServiceStatus.HEALTHCHECK_PASS if self.run_healthcheck(process) else SmServiceStatus.HEALTHCHECK_BOOT
            return SmServiceStatus.for_process(self.service_name, process, port, test_id, run_from, features, healthcheck)

        return map(_status_for_process, processes)
开发者ID:vaughansharman,项目名称:service-manager,代码行数:12,代码来源:smjvmservice.py


示例7: test_successful_play_from_jar_without_waiting_with_append_args

    def test_successful_play_from_jar_without_waiting_with_append_args(self):
        sm_application = SmApplication(self.config_dir_override)
        context = SmContext(sm_application, None, False, False)
        service_resolver = ServiceResolver(sm_application)

        context.kill_everything(True)

        self.startFakeNexus()

        servicetostart = ["PLAY_NEXUS_END_TO_END_TEST"]
        appendArgs = {"PLAY_NEXUS_END_TO_END_TEST": ["-DFoo=Bar"]}
        fatJar = True
        release = False
        proxy = None
        port = None
        seconds_to_wait = None

        actions.start_and_wait(service_resolver, context, servicetostart, False, fatJar, release, proxy, port, seconds_to_wait, appendArgs)
        service = SmPlayService(context, "PLAY_NEXUS_END_TO_END_TEST")
        self.waitForCondition(lambda : len(SmProcess.processes_matching(service.pattern)), 1)
        processes = SmProcess.processes_matching(service.pattern)
        self.assertTrue("-DFoo=Bar" in processes[0].args)
开发者ID:elabeca,项目名称:service-manager,代码行数:22,代码来源:test_actions.py


示例8: status

    def status(self):
        processes = SmProcess.processes_matching(SmPythonService.get_pattern(self))

        if len(processes) == 0:
            return []

        if len(processes) > 1:
            self.log("POSSIBLE PROBLEM: Found more than one process")

        def _status_for_process(process):
            healthcheck = SmServiceStatus.HEALTHCHECK_PASS if self.run_healthcheck(None) else SmServiceStatus.HEALTHCHECK_BOOT
            return SmServiceStatus.for_process(self.service_name, process, self.default_port, "", "", "", healthcheck)

        return map(_status_for_process, processes)
开发者ID:eamonnfaherty,项目名称:service-manager,代码行数:14,代码来源:smpythonservice.py


示例9: test_external_with_append_args

    def test_external_with_append_args(self):
        context = self.createContext()
        server = smserverlogic.SmServer(SmApplication(self.config_dir_override, None))
        request = dict()
        request["testId"] = "foo"
        request["services"] = [{"serviceName": "TEST_FOUR", "runFrom": "SNAPSHOT", "appendArgs": ["2"]}]
        smserverlogic.SmStartRequest(server, request, True, False, False, True).process_request()
        self.assertIsNotNone(context.get_service("TEST_FOUR").status())
        pattern = context.application.services["TEST_FOUR"]["pattern"]

        self.waitForCondition(lambda : len(SmProcess.processes_matching(pattern)), 1)

        context.kill_everything(True)
        self.assertEqual(context.get_service("TEST_FOUR").status(), [])
开发者ID:hmrc,项目名称:service-manager,代码行数:14,代码来源:test_server.py


示例10: test_external_with_append_args

 def test_external_with_append_args(self):
     config_dir_override = os.path.join(os.path.dirname(__file__), "conf")
     context = SmContext(SmApplication(config_dir_override), None, False, False)
     context.kill_everything()
     server = smserverlogic.SmServer(SmApplication(config_dir_override, None))
     request = dict()
     request["testId"] = "foo"
     request["services"] = [{"serviceName": "TEST_ONE", "runFrom": "SNAPSHOT", "appendArgs": [";echo foo"]}]
     smserverlogic.SmStartRequest(server, request, True, False).process_request()
     self.assertIsNotNone(context.get_service("TEST_ONE").status())
     pattern = context.application.services["TEST_ONE"]["pattern"]
     processes = SmProcess.processes_matching(pattern)
     # stop does not currently work for extern
     # smserverlogic.SmStopRequest(SERVER, request).process_request()
     self.assertEqual(len(processes), 2) #we expect two proecesses to be spawned because of the appended command
     self.assertTrue(";echo" in processes[0].args or ";echo" in processes[1].args)
     context.kill_everything()
     self.assertEqual(context.get_service("TEST_ONE").status(), [])
开发者ID:liquidarmour,项目名称:service-manager,代码行数:18,代码来源:tests.py


示例11: status

    def status(self, all_processes=None):
        processes = SmProcess.processes_matching(self.pattern, all_processes)

        if len(processes) == 0:
            return []

        if len(processes) > 1:
            self.log("POSSIBLE PROBLEM: Found more than one process")

        def _status_for_process(process):
            hc_result = self.run_healthcheck(process)
            healthcheck = SmServiceStatus.HEALTHCHECK_NONE
            if hc_result is not None:
                healthcheck = SmServiceStatus.HEALTHCHECK_PASS if self.run_healthcheck(process) else SmServiceStatus.HEALTHCHECK_BOOT
            return SmServiceStatus.for_process(self.service_name, process, "", "", "", "", healthcheck)


        return map(_status_for_process, processes)
开发者ID:elabeca,项目名称:service-manager,代码行数:18,代码来源:smexternalservice.py


示例12: test_play_with_append_args

    def test_play_with_append_args(self):
        context = self.createContext()
        self.startFakeNexus()

        server = smserverlogic.SmServer(SmApplication(self.config_dir_override, None))
        request = dict()
        request["testId"] = "foo"
        request["services"] = [{"serviceName": "PLAY_NEXUS_END_TO_END_TEST", "runFrom": "SNAPSHOT", "appendArgs": ["-Dfoo=bar"]}]
        smserverlogic.SmStartRequest(server, request, True, False, False, True).process_request()

        self.waitForCondition(lambda : len(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status()), 1)

        service = SmPlayService(context, "PLAY_NEXUS_END_TO_END_TEST")
        processes = SmProcess.processes_matching(service.pattern)
        self.assertEqual(len(processes), 1)
        self.assertTrue("-Dfoo=bar" in processes[0].args)

        context.kill_everything(True)
        self.assertEqual(context.get_service("PLAY_NEXUS_END_TO_END_TEST").status(), [])
开发者ID:hmrc,项目名称:service-manager,代码行数:19,代码来源:test_server.py


示例13: _wait_for_services

def _wait_for_services(context, service_names, seconds_to_wait):

    waiting_for_services = []

    for service_name in service_names:
        if "healthcheck" in context.service_data(service_name):
            waiting_for_services += [context.get_service(service_name)]

    if not seconds_to_wait:
        seconds_to_wait = 0

    end_time = _now() + seconds_to_wait

    while waiting_for_services and _now() < end_time:

        services_to_check = list(waiting_for_services)

        for service in services_to_check:

            if _now() >= end_time:
                break

            processes = SmProcess.processes_matching(service.pattern)
            if all(map(service.run_healthcheck, processes)):
                print "Service '%s' has started successfully" % service.service_name
                waiting_for_services.remove(service)
            else:
                seconds_remaining = end_time - _now()
                if seconds_remaining % 5 == 0 or seconds_remaining < 10:
                    print "Waiting for %s to start, %s second%s before timeout" % (service.service_name, seconds_remaining, "s" if seconds_to_wait != 1 else "")

        if waiting_for_services:
            time.sleep(1)

    if waiting_for_services:
        services_timed_out = []
        for service in waiting_for_services:
            services_timed_out += [service.service_name]
        raise ServiceManagerException("Timed out starting service(s): %s" % ", ".join(services_timed_out))
开发者ID:eamonnfaherty,项目名称:service-manager,代码行数:39,代码来源:actions.py


示例14: is_started_on_default_port

 def is_started_on_default_port(self):
     return len(SmProcess.processes_matching(SmPythonService.get_pattern(self))) > 0
开发者ID:eamonnfaherty,项目名称:service-manager,代码行数:2,代码来源:smpythonservice.py


示例15: is_started_on_default_port

 def is_started_on_default_port(self):
     return len(SmProcess.processes_matching(self.pattern)) > 0
开发者ID:eamonnfaherty,项目名称:service-manager,代码行数:2,代码来源:smexternalservice.py


示例16: stop

 def stop(self, wait=False):
     for process in SmProcess.processes_matching(self.pattern):
         kill_pid(self.context, process.ppid, wait=wait)
         kill_pid(self.context, process.pid, wait=wait)
         self.context.log("name: %s\tppid: %s\tpid: %s\tuptime: %s" % (self.service_name, process.ppid, process.pid, process.uptime), True)
     self.post_stop()
开发者ID:hmrc,项目名称:service-manager,代码行数:6,代码来源:smjvmservice.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python servicemigration.require函数代码示例发布时间:2022-05-27
下一篇:
Python smcontext.SmContext类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap