コード例 #1
0
ファイル: service.py プロジェクト: nvaidya1/optf-has
    def run(self):
        transport = messaging.get_transport(self.conf)
        if transport:
            topic = "controller"
            target = music_messaging.Target(topic=topic)
            endpoints = [
                rpc.ControllerRPCEndpoint(self.conf, self.Plan),
            ]
            flush = not self.conf.controller.concurrent
            kwargs = {
                'transport': transport,
                'target': target,
                'endpoints': endpoints,
                'flush': flush,
            }
            svcmgr = cotyledon.ServiceManager()
            svcmgr.add(music_messaging.RPCService,
                       workers=self.conf.controller.workers,
                       args=(self.conf, ),
                       kwargs=kwargs)

            kwargs = {'plan_class': self.Plan, 'order_locks': self.OrderLock}
            svcmgr.add(translator_svc.TranslatorService,
                       workers=self.conf.controller.workers,
                       args=(self.conf, ),
                       kwargs=kwargs)
            svcmgr.run()
コード例 #2
0
def main():
    conf = service.prepare_service()
    sm = cotyledon.ServiceManager()
    sm.add(collector.CollectorService,
           workers=conf.collector.workers,
           args=(conf, ))
    sm.run()
コード例 #3
0
def main():
    print(VITRAGE_TITLE)
    config.parse_config(sys.argv)
    db_connection = storage.get_connection_from_config()
    sm = cotyledon.ServiceManager()
    sm.add(PersistorService, args=(db_connection, ))
    sm.run()
コード例 #4
0
ファイル: persistor.py プロジェクト: ngohoa211/vitrage-1
def main():
    print(VITRAGE_TITLE)
    conf = service.prepare_service()
    db_connection = storage.get_connection_from_config(conf)
    sm = cotyledon.ServiceManager()
    sm.add(PersistorService, args=(conf, db_connection))
    sm.run()
コード例 #5
0
ファイル: examples.py プロジェクト: toabctl/cotyledon
def window_sanity_check():
    p = cotyledon.ServiceManager()
    p.add(LigthService)
    t = _utils.spawn(p.run)
    time.sleep(10)
    os.kill(os.getpid(), signal.SIGTERM)
    t.join()
コード例 #6
0
    def test_invalid_service(self):
        sm = cotyledon.ServiceManager()

        self.assertRaisesMsg(
            ValueError,
            "'service' must be a callable",
            sm.add, u"foo")
        self.assertRaisesMsg(
            ValueError,
            "'workers' must be an int >= 1, not: None (NoneType)",
            sm.add, FakeService, workers=None)
        self.assertRaisesMsg(
            ValueError,
            "'workers' must be an int >= 1, not: -2 (int)",
            sm.add, FakeService, workers=-2)

        oid = sm.add(FakeService, workers=3)
        self.assertRaisesMsg(
            ValueError,
            "'workers' must be an int >= -2, not: -5 (int)",
            sm.reconfigure, oid, workers=-5)
        self.assertRaisesMsg(
            ValueError,
            "notexists service id doesn't exists",
            sm.reconfigure, "notexists", workers=-1)
コード例 #7
0
def main():
    conf = ConfigParser.ConfigParser()
    service.service_prepare(config_file=sys.argv[1], conf=conf)
    logger.info("The config path is:%s" % conf.get('DEFAULT', 'conf_path'))
    sm = cotyledon.ServiceManager()
    sm.add(create_agent, args=(conf,))
    sm.run()
コード例 #8
0
def run_app():
    # set lock file
    # NOTE: file may already be locked if someone tries to check it's locked status by trying to lock it again,
    #   this is why we try several times to lock the file in case it couldn't lock it
    lock_file_retries = 5
    lock_file_success = False
    error_msg = 'Could not set lock on updated_lock.pid file. Updated status may show as not running in staff panel.'
    while lock_file_retries and lock_file_success is False:
        try:
            fp = open(
                getattr(django_settings, 'UPDATED_LOCK_FILE',
                        '/var/fleio/updated_lock.pid'), 'a+')
        except FileNotFoundError:
            error_msg = 'Could not create updated_lock.pid file'
            break
        try:
            fcntl.flock(fp.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
        except IOError:
            lock_file_success = False
        else:
            # locking file succeeded
            lock_file_success = True
        lock_file_retries -= 1
        if lock_file_success is False:
            # wait only if we could not set the lock
            time.sleep(2)
    if not lock_file_success:
        LOG.error(error_msg)

    reload_event = multiprocessing.Event()
    p = cotyledon.ServiceManager()
    p.add(UpdatedService, kwargs={'reload_event': reload_event})
    p.add(SettingsCheck, kwargs={'reload_event': reload_event})
    p.add(OsOperations, kwargs={'reload_event': reload_event})
    p.run()
コード例 #9
0
def main():
    conf = service.prepare_service()
    sm = cotyledon.ServiceManager()
    sm.add(collector.CollectorService, workers=conf.collector.workers,
           args=(conf,))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #10
0
def main():
    conf = service.prepare_service()

    sm = cotyledon.ServiceManager()
    sm.add(notification.NotificationService,
           workers=conf.notification.workers,
           args=(conf, ))
    sm.run()
コード例 #11
0
ファイル: examples.py プロジェクト: toabctl/cotyledon
def example_app():
    p = cotyledon.ServiceManager()
    p.add(FullService, 2)
    service_id = p.add(LigthService, 5)
    p.reconfigure(service_id, 1)
    p.register_hooks(on_terminate, on_reload)
    p.register_hooks(on_terminate2)
    p.run()
コード例 #12
0
 def run(self):
     kwargs = {'plan_class': self.Plan, 'order_locks': self.OrderLock}
     svcmgr = cotyledon.ServiceManager()
     svcmgr.add(ReservationService,
                workers=self.conf.reservation.workers,
                args=(self.conf, ),
                kwargs=kwargs)
     svcmgr.run()
コード例 #13
0
def main():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts(CLI_OPTS)
    service.prepare_service(conf=conf)
    sm = cotyledon.ServiceManager()
    sm.add(create_polling_service, args=(conf, ))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #14
0
def main():
    """Starts all the datasources drivers services"""

    print(VITRAGE_TITLE)
    conf = service.prepare_service()
    sm = cotyledon.ServiceManager()
    sm.add(CollectorService, args=(conf, ))
    sm.run()
コード例 #15
0
def main():
    conf = service.prepare_service()

    sm = cotyledon.ServiceManager()
    sm.add(notification.NotificationService,
           workers=conf.notification.workers,
           args=(conf, ))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #16
0
def sigterm_during_init():
    def kill():
        os.kill(os.getpid(), signal.SIGTERM)

    # Kill in 0.01 sec
    threading.Timer(0.01, kill).start()
    p = cotyledon.ServiceManager()
    p.add(LigthService, 10)
    p.run()
コード例 #17
0
def main():
    octavia_service.prepare_service(sys.argv)
    gmr.TextGuruMeditation.setup_autorun(version)
    sm = cotyledon.ServiceManager()
    sm.add(consumer.ConsumerService,
           workers=CONF.a10_controller_worker.workers,
           args=(CONF, ))
    oslo_config_glue.setup(sm, CONF, reload_method="mutate")
    sm.run()
コード例 #18
0
def example_app():
    logging.basicConfig(level=logging.DEBUG)
    p = cotyledon.ServiceManager()
    p.add(FullService, 2)
    service_id = p.add(LigthService, 5)
    p.reconfigure(service_id, 1)
    p.register_hooks(on_terminate, on_reload)
    p.register_hooks(on_terminate2)
    p.run()
コード例 #19
0
def main():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts(CLI_OPTS)
    service.prepare_service(conf=conf)
    priv_context.init(root_helper=shlex.split(utils._get_root_helper()))
    sm = cotyledon.ServiceManager()
    sm.add(create_polling_service, args=(conf, ))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #20
0
def start(is_service):
    """main method"""
    df_config.init(sys.argv)
    df_utils.config_parse()
    nb_api = api_nb.NbApi.get_instance(False)
    if is_service:
        df_service.register_service('df-skydive-service', nb_api)
    service_manager = cotyledon.ServiceManager()
    service_manager.add(SkydiveClient, workers=1, args=(nb_api, ))
    service_manager.run()
コード例 #21
0
def main():
    service.prepare_service()

    sm = cotyledon.ServiceManager()
    sm.add(manager.BackupManager, workers=CONF.conductor.backup_workers, args=(CONF,))
    sm.add(
        manager.RotationManager, workers=CONF.conductor.rotation_workers, args=(CONF,)
    )
    oslo_config_glue.setup(sm, CONF)
    sm.run()
コード例 #22
0
def main():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts(pipeline.OPTS)
    service.prepare_service(conf=conf)

    sm = cotyledon.ServiceManager()
    sm.add(notification.NotificationService,
           workers=conf.notification.workers,
           args=(conf, ))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #23
0
ファイル: examples.py プロジェクト: toabctl/cotyledon
def oslo_app():
    conf = cfg.ConfigOpts()
    conf([],
         project='openstack-app',
         validate_default_values=True,
         version="0.1")

    p = cotyledon.ServiceManager()
    oslo_config_glue.setup(p, conf)
    p.add(OsloService)
    p.run()
コード例 #24
0
ファイル: polling.py プロジェクト: Dany9966/ceilometer
def main():
    sm = cotyledon.ServiceManager()
    # On Windows, we can only initialize conf objects in the subprocess.
    # As a consequence, we can't use oslo_config_glue.setup() on Windows,
    # because cotyledon.ServiceManager objects are not picklable.
    if os.name == 'nt':
        sm.add(create_polling_service)
    else:
        conf = _prepare_config()
        oslo_config_glue.setup(sm, conf)
        sm.add(create_polling_service, args=(conf,))
    sm.run()
コード例 #25
0
 def test_forking_slowdown(self):
     sm = cotyledon.ServiceManager()
     sm.add(FakeService, workers=3)
     with mock.patch('time.sleep') as sleep:
         sm._slowdown_respawn_if_needed()
         sm._slowdown_respawn_if_needed()
         sm._slowdown_respawn_if_needed()
         # We simulatge 3 more spawn
         sm._slowdown_respawn_if_needed()
         sm._slowdown_respawn_if_needed()
         sm._slowdown_respawn_if_needed()
         self.assertEqual(6, len(sleep.mock_calls))
コード例 #26
0
def exit_on_special_child_app():
    p = cotyledon.ServiceManager()
    sid = p.add(LigthService, 1)
    p.add(FullService, 2)

    def on_dead_worker(service_id, worker_id, exit_code):
        # Shutdown everybody if LigthService died
        if service_id == sid:
            p.shutdown()

    p.register_hooks(on_dead_worker=on_dead_worker)
    p.run()
コード例 #27
0
ファイル: service.py プロジェクト: nvaidya1/optf-has
 def run(self):
     kwargs = {'plan_class': self.Plan,
               'order_locks': self.OrderLock,
               'order_locks_history': self.OrderLockHistory,
               'region_placeholders': self.RegionPlaceholders,
               'country_latency': self.CountryLatency,
               'triage_tool': self.TriageTool
               }
     # kwargs = {'plan_class': self.Plan}
     svcmgr = cotyledon.ServiceManager()
     svcmgr.add(SolverService,
                workers=self.conf.solver.workers,
                args=(self.conf,), kwargs=kwargs)
     svcmgr.run()
コード例 #28
0
ファイル: engine.py プロジェクト: baikai/qinling
def main():
    try:
        config.parse_args(args=common.get_properly_ordered_parameters())
        common.print_server_info("engine")
        logging.setup(CONF, 'qinling')
        # Initialize RPC configuration.
        rpc.get_transport()

        sm = cotyledon.ServiceManager()
        sm.add(
            eng_service.EngineService,
            workers=1,
        )
        sm.run()
    except RuntimeError as excp:
        sys.stderr.write("ERROR: %s\n" % excp)
        sys.exit(1)
コード例 #29
0
ファイル: service.py プロジェクト: dileepranganathan/optf-has
 def run(self):
     transport = messaging.get_transport(self.conf)
     if transport:
         topic = "data"
         target = music_messaging.Target(topic=topic)
         endpoints = [
             DataEndpoint(self.ip_ext_manager, self.vc_ext_manager,
                          self.sc_ext_manager),
         ]
         flush = not self.conf.data.concurrent
         kwargs = {
             'transport': transport,
             'target': target,
             'endpoints': endpoints,
             'flush': flush,
         }
         svcmgr = cotyledon.ServiceManager()
         svcmgr.add(music_messaging.RPCService,
                    workers=self.conf.data.workers,
                    args=(self.conf, ),
                    kwargs=kwargs)
         svcmgr.run()
コード例 #30
0
def example2_18():
    import threading
    import time

    import cotyledon

    class PrinterService(cotyledon.Service):
        name = "printer"

        def __init__(self, worker_id) -> None:
            self._shutdown = threading.Event()

        def run(self):
            while not self._shutdown.is_set():
                print("Doing stuff")
                time.sleep()

        def terminate(self):
            self._shutdown.set()

    manager = cotyledon.ServiceManager()  # manager 생성
    manager.add(PrinterService, 2)  # printerService 두 개 실행
    manager.run()  # 추가된 작업 모두 실행