當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。