Пример #1
0
 def test_start_arbiter_with_autostart(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=get_ioloop(),
                       check_delay=-1)
     arbiter.add_watcher('foo', SLEEP % 5, autostart=False)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'stopped')
     finally:
         yield arbiter.stop()
Пример #2
0
 def test_start_arbiter_with_autostart(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=get_ioloop(),
                       check_delay=-1)
     arbiter.add_watcher('foo', SLEEP % 5, autostart=False)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'stopped')
     finally:
         yield arbiter.stop()
Пример #3
0
 def test_start_arbiter_with_autostart(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=tornado.ioloop.IOLoop.instance(),
                       check_delay=-1)
     arbiter.add_watcher('foo', 'sleep 5', autostart=False)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'stopped')
     finally:
         yield arbiter.stop()
Пример #4
0
 def test_add_watcher(self):
     controller = "tcp://127.0.0.1:%d" % get_available_port()
     sub = "tcp://127.0.0.1:%d" % get_available_port()
     arbiter = Arbiter([], controller, sub, loop=get_ioloop(),
                       check_delay=-1)
     arbiter.add_watcher('foo', SLEEP % 5)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'active')
     finally:
         yield arbiter.stop()
Пример #5
0
 def test_circushttpd(self):
     arbiter = Arbiter([], DEFAULT_ENDPOINT_DEALER, DEFAULT_ENDPOINT_SUB,
                       loop=tornado.ioloop.IOLoop.instance(),
                       check_delay=-1, httpd=True, debug=True)
     self.arbiters.append(arbiter)
     try:
         yield arbiter.start()
         poll_for_callable(self.assertDictEqual,
                           arbiter.statuses, {'circushttpd': 'active'})
     finally:
         yield arbiter.stop()
Пример #6
0
 def test_add_watcher(self):
     controller = "tcp://127.0.0.1:%d" % get_available_port()
     sub = "tcp://127.0.0.1:%d" % get_available_port()
     arbiter = Arbiter([], controller, sub, loop=get_ioloop(),
                       check_delay=-1)
     arbiter.add_watcher('foo', SLEEP % 5)
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'active')
     finally:
         yield arbiter.stop()
Пример #7
0
 def test_add_watcher(self):
     arbiter = Arbiter([],
                       DEFAULT_ENDPOINT_DEALER,
                       DEFAULT_ENDPOINT_SUB,
                       loop=tornado.ioloop.IOLoop.instance(),
                       check_delay=-1)
     arbiter.add_watcher('foo', 'sleep 5')
     try:
         yield arbiter.start()
         self.assertEqual(arbiter.watchers[0].status(), 'active')
     finally:
         yield arbiter.stop()
Пример #8
0
    def test_circushttpd(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()

        arbiter = Arbiter([], controller, sub, loop=get_ioloop(),
                          check_delay=-1, httpd=True, debug=True)
        self.arbiters.append(arbiter)
        try:
            yield arbiter.start()
            poll_for_callable(self.assertDictEqual,
                              arbiter.statuses, {'circushttpd': 'active'})
        finally:
            yield arbiter.stop()
Пример #9
0
    def test_circushttpd(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()

        arbiter = Arbiter([], controller, sub, loop=get_ioloop(),
                          check_delay=-1, httpd=True, debug=True)
        self.arbiters.append(arbiter)
        try:
            yield arbiter.start()
            poll_for_callable(self.assertDictEqual,
                              arbiter.statuses, {'circushttpd': 'active'})
        finally:
            yield arbiter.stop()
Пример #10
0
    def test_start_with_callback_and_given_loop(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()
        arbiter = Arbiter([], controller, sub, check_delay=-1,
                          loop=get_ioloop())

        callback = mock.MagicMock()

        try:
            yield arbiter.start(cb=callback)
        finally:
            yield arbiter.stop()

        self.assertEqual(callback.call_count, 0)
Пример #11
0
    def test_start_with_callback_and_given_loop(self):
        controller = "tcp://127.0.0.1:%d" % get_available_port()
        sub = "tcp://127.0.0.1:%d" % get_available_port()
        arbiter = Arbiter([], controller, sub, check_delay=-1,
                          loop=get_ioloop())

        callback = mock.MagicMock()

        try:
            yield arbiter.start(cb=callback)
        finally:
            yield arbiter.stop()

        self.assertEqual(callback.call_count, 0)
Пример #12
0
 def test_circushttpd(self):
     arbiter = Arbiter([],
                       DEFAULT_ENDPOINT_DEALER,
                       DEFAULT_ENDPOINT_SUB,
                       loop=tornado.ioloop.IOLoop.instance(),
                       check_delay=-1,
                       httpd=True,
                       debug=True)
     self.arbiters.append(arbiter)
     try:
         yield arbiter.start()
         poll_for_callable(self.assertDictEqual, arbiter.statuses,
                           {'circushttpd': 'active'})
     finally:
         yield arbiter.stop()
Пример #13
0
                    limit = cfg_name[7:]
                    rlimits[limit] = int(cfg_value)

            watcher = Watcher(name, cmd, numprocesses=numprocesses,
                        warmup_delay=warmup_delay, working_dir=working_dir,
                        shell=shell, uid=uid, gid=gid, send_hup=send_hup,
                        times=times, within=within, retry_in=retry_in,
                        max_retry=max_retry, graceful_timeout=graceful_timeout,
                        rlimits=rlimits)

            watchers.append(watcher)

    # main circus options
    check = cfg.dget('circus', 'check_delay', 5, int)
    endpoint = cfg.dget('circus', 'endpoint', 'tcp://127.0.0.1:5555')
    pubsub_endpoint = cfg.dget('circus', 'pubsub_endpoint',
            'tcp://127.0.0.1:5556')

    arbiter = Arbiter(watchers, endpoint, pubsub_endpoint, check)
    try:
        arbiter.start()
    finally:
        arbiter.stop()
        if pidfile is not None:
            pidfile.unlink()

    sys.exit(0)

if __name__ == '__main__':
    main()