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


Python NginxManager._find_all方法代码示例

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


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

示例1: test_find_all

# 需要导入模块: from amplify.agent.managers.nginx import NginxManager [as 别名]
# 或者: from amplify.agent.managers.nginx.NginxManager import _find_all [as 别名]
    def test_find_all(self):
        out = subp.call('ps xao pid,ppid,command | grep "supervisor[d]" | tr -s " "')[0]
        supervisors = [map(int, line.strip().split()[:2]) for line in out if 'supervisord' in line]
        assert_that(supervisors, has_length(1))
        supervisor_pid, supervisor_ppid = supervisors[0]
        assert_that(supervisor_ppid, equal_to(1))

        time.sleep(2)

        out = subp.call('ps xao pid,ppid,command | grep "nginx[:]" | tr -s " "')[0]
        masters = [map(int, line.strip().split()[:2]) for line in out if 'nginx: master process' in line]
        assert_that(masters, has_length(1))
        master_pid, master_ppid = masters[0]
        assert_that(master_ppid, equal_to(supervisor_pid))

        worker_pids = []

        workers = [map(int, line.strip().split()[:2]) for line in out if 'nginx: worker process' in line]
        for worker_pid, worker_ppid in workers:
            worker_pids.append(worker_pid)
            assert_that(worker_ppid, equal_to(master_pid))

        container = NginxManager()
        nginxes = container._find_all()
        assert_that(nginxes, has_length(1))

        definition, data = nginxes.pop(0)
        assert_that(data, has_key('pid'))
        assert_that(data, has_key('workers'))

        assert_that(master_pid, equal_to(data['pid']))
        assert_that(worker_pids, equal_to(data['workers']))
开发者ID:nginxinc,项目名称:nginx-amplify-agent,代码行数:34,代码来源:nginx.py

示例2: test_find_all

# 需要导入模块: from amplify.agent.managers.nginx import NginxManager [as 别名]
# 或者: from amplify.agent.managers.nginx.NginxManager import _find_all [as 别名]
    def test_find_all(self):
        container = NginxManager()
        nginxes = container._find_all()
        assert_that(nginxes, has_length(1))

        definition, data = nginxes.pop(0)
        assert_that(data, has_key('pid'))
        assert_that(data, has_key('workers'))

        # get ps info
        master, workers = self.get_master_workers()

        assert_that(master, equal_to(data['pid']))
        assert_that(workers, equal_to(data['workers']))
开发者ID:MSmmer,项目名称:nginx-amplify-agent,代码行数:16,代码来源:nginx.py

示例3: test_find_none

# 需要导入模块: from amplify.agent.managers.nginx import NginxManager [as 别名]
# 或者: from amplify.agent.managers.nginx.NginxManager import _find_all [as 别名]
    def test_find_none(self):
        # Kill running NGINX so that it finds None
        subp.call('pgrep nginx |sudo xargs kill -SIGKILL', check=False)
        self.running = False

        # Setup dummy object
        context.objects.register(DummyRootObject())

        container = NginxManager()
        nginxes = container._find_all()
        assert_that(nginxes, has_length(0))

        root_object = context.objects.root_object
        assert_that(root_object.eventd.current, has_length(1))

        # Reset objects...
        context.objects = None
        context._setup_object_tank()
开发者ID:nginxinc,项目名称:nginx-amplify-agent,代码行数:20,代码来源:nginx.py


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