예제 #1
0
    def wait(self):
        """Loop waiting on children to die and respawning as necessary."""

        systemd.notify_once()
        LOG.debug('Full set of CONF:')
        CONF.log_opt_values(LOG, logging.DEBUG)

        try:
            while True:
                self.handle_signal()
                self._respawn_children()
                # No signal means that stop was called.  Don't clean up here.
                if not self.sigcaught:
                    return

                signame = _signo_to_signame(self.sigcaught)
                LOG.info(_LI('Caught %s, stopping children'), signame)
                if not _is_sighup_and_daemon(self.sigcaught):
                    break

                cfg.CONF.reload_config_files()
                for service in set(
                        [wrap.service for wrap in self.children.values()]):
                    service.reset()

                for pid in self.children:
                    os.kill(pid, signal.SIGHUP)

                self.running = True
                self.sigcaught = None
        except eventlet.greenlet.GreenletExit:
            LOG.info(_LI("Wait called after thread killed. Cleaning up."))

        self.stop()
예제 #2
0
    def _test__sd_notify(self, getenv_mock, unset_env=False):
        self.ready = False
        self.closed = False

        class FakeSocket(object):
            def __init__(self, family, type):
                pass

            def connect(fs, socket):
                pass

            def close(fs):
                self.closed = True

            def sendall(fs, data):
                if data == b'READY=1':
                    self.ready = True

        with mock.patch.object(socket, 'socket', new=FakeSocket):
            if unset_env:
                systemd.notify_once()
            else:
                systemd.notify()

            self.assertTrue(self.ready)
            self.assertTrue(self.closed)
예제 #3
0
    def _test__sd_notify(self, getenv_mock, unset_env=False):
        self.ready = False
        self.closed = False

        class FakeSocket(object):
            def __init__(self, family, type):
                pass

            def connect(fs, socket):
                pass

            def close(fs):
                self.closed = True

            def sendall(fs, data):
                if data == b'READY=1':
                    self.ready = True

        with mock.patch.object(socket, 'socket', new=FakeSocket):
            if unset_env:
                systemd.notify_once()
            else:
                systemd.notify()

            self.assertTrue(self.ready)
            self.assertTrue(self.closed)
예제 #4
0
def main():
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project='heat',
                 prog='heat-api',
                 version=version.version_info.version_string())
        logging.setup(cfg.CONF, 'heat-api')
        messaging.setup()

        app = config.load_paste_app()

        port = cfg.CONF.heat_api.bind_port
        host = cfg.CONF.heat_api.bind_host
        LOG.info(_LI('Starting Heat REST API on %(host)s:%(port)s'), {
            'host': host,
            'port': port
        })
        profiler.setup('heat-api', host)
        gmr.TextGuruMeditation.setup_autorun(version)
        server = wsgi.Server('heat-api', cfg.CONF.heat_api)
        server.start(app, default_port=port)
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #5
0
파일: api.py 프로젝트: rickyhai11/kingbird
def main():
    api_config.init(sys.argv[1:])
    api_config.setup_logging()
    application = app.setup_app()

    host = CONF.bind_host
    port = CONF.bind_port
    workers = CONF.api_workers

    if workers < 1:
        LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers)
        workers = 1

    LOG.info(_LI("Server on http://%(host)s:%(port)s with %(workers)s"),
             {'host': host, 'port': port, 'workers': workers})
    messaging.setup()
    systemd.notify_once()
    service = wsgi.Server(CONF, "Kingbird", application, host, port)

    app.serve(service, CONF, workers)

    LOG.info(_LI("Configuration:"))
    CONF.log_opt_values(LOG, std_logging.INFO)

    app.wait()
예제 #6
0
def main():

    config.init(sys.argv[1:])
    config.setup_logging()

    application = app.load_paste_app()

    CONF.register_opts(api_opts, 'api')

    host = CONF.api.bind_host
    port = CONF.api.bind_port
    workers = CONF.api.api_workers

    if workers < 1:
        LOG.warning("Wrong worker number, worker = %(workers)s", workers)
        workers = 1

    LOG.info("Server on http://%(host)s:%(port)s with %(workers)s", {
        'host': host,
        'port': port,
        'workers': workers
    })
    systemd.notify_once()
    service = wsgi.Server(CONF, CONF.prog, application, host, port)

    app.serve(service, CONF, workers)

    LOG.debug("Configuration:")
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    app.wait()
예제 #7
0
파일: api.py 프로젝트: zhouqiang-cl/senlin
def main():
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project='senlin',
                 prog='senlin-api',
                 version=version.version_info.version_string())
        config.set_config_defaults()
        logging.setup(cfg.CONF, 'senlin-api')
        objects.register_all()
        messaging.setup()

        app = wsgi.load_paste_app()

        host = cfg.CONF.senlin_api.bind_host
        port = cfg.CONF.senlin_api.bind_port
        LOG.info('Starting Senlin API on %(host)s:%(port)s', {
            'host': host,
            'port': port
        })
        profiler.setup('senlin-api', host)
        server = wsgi.Server('senlin-api', cfg.CONF.senlin_api)
        server.start(app, default_port=port)
        systemd.notify_once()
        server.wait()
    except RuntimeError as ex:
        sys.exit("ERROR: %s" % six.text_type(ex))
예제 #8
0
def main():
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project='heat',
                 prog='heat-api-cloudwatch',
                 version=version.version_info.version_string())
        logging.setup(cfg.CONF, 'heat-api-cloudwatch')
        logging.set_defaults()
        messaging.setup()

        app = config.load_paste_app()

        port = cfg.CONF.heat_api_cloudwatch.bind_port
        host = cfg.CONF.heat_api_cloudwatch.bind_host
        LOG.info(_LI('Starting Heat CloudWatch API on %(host)s:%(port)s'),
                 {'host': host, 'port': port})
        profiler.setup('heat-api-cloudwatch', host)
        gmr.TextGuruMeditation.setup_autorun(version)
        server = wsgi.Server('heat-api-cloudwatch',
                             cfg.CONF.heat_api_cloudwatch)
        server.start(app, default_port=port)
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #9
0
    def wait(self):
        """Loop waiting on children to die and respawning as necessary."""

        systemd.notify_once()
        if self.conf.log_options:
            LOG.debug('Full set of CONF:')
            self.conf.log_opt_values(LOG, logging.DEBUG)

        try:
            while True:
                self.handle_signal()
                self._respawn_children()
                # No signal means that stop was called.  Don't clean up here.
                if not self.sigcaught:
                    return

                signame = _signals_to_name[self.sigcaught]
                LOG.info(_LI('Caught %s, stopping children'), signame)
                if not _is_sighup_and_daemon(self.sigcaught):
                    break

                self.conf.reload_config_files()
                for service in set(
                    [wrap.service for wrap in self.children.values()]):
                    service.reset()

                for pid in self.children:
                    os.kill(pid, signal.SIGHUP)

                self.running = True
                self.sigcaught = None
        except eventlet.greenlet.GreenletExit:
            LOG.info(_LI("Wait called after thread killed. Cleaning up."))

        self.stop()
예제 #10
0
def main():
    api_config.init(sys.argv[1:])
    api_config.setup_logging()

    messaging.setup()
    dcmanager_messaging.setup()

    application = app.load_paste_app()

    if CONF.type not in consts.ENDPOINT_TYPES_LIST:
        LOG.error("Unsupported endpoint type: (%s)", CONF.type)
        sys.exit(1)

    CONF.register_opts(proxy_opts, CONF.type)

    host, port = utils.get_host_port_options(CONF)
    workers = CONF.api_workers

    if workers < 1:
        LOG.warning("Wrong worker number, worker = %(workers)s", workers)
        workers = 1

    LOG.info("Server on http://%(host)s:%(port)s with %(workers)s",
             {'host': host, 'port': port, 'workers': workers})
    systemd.notify_once()
    service = wsgi.Server(CONF, CONF.prog, application, host, port)

    app.serve(service, CONF, workers)

    LOG.info("Configuration:")
    CONF.log_opt_values(LOG, std_logging.INFO)

    app.wait()
예제 #11
0
def main():
    api_config.init(sys.argv[1:])
    api_config.setup_logging()
    application = app.setup_app()

    host = CONF.bind_host
    port = CONF.bind_port
    workers = CONF.api_workers

    if workers < 1:
        LOG.warning("Wrong worker number, worker = %(workers)s", workers)
        workers = 1

    LOG.info("Server on http://%(host)s:%(port)s with %(workers)s", {
        'host': host,
        'port': port,
        'workers': workers
    })
    messaging.setup()
    systemd.notify_once()
    service = wsgi.Server(CONF, "OrchEngine", application, host, port)

    app.serve(service, CONF, workers)

    LOG.info("Configuration:")
    CONF.log_opt_values(LOG, std_logging.INFO)

    app.wait()
예제 #12
0
    def start(self, application, port, host='0.0.0.0', workers=0):
        """Run a WSGI server with the given application."""
        #设置服务要绑定的host,port
        self._host = host
        self._port = port
        backlog = CONF.backlog

        #创建监听socket
        self._socket = self._get_socket(self._host,
                                        self._port,
                                        backlog=backlog)
        if workers < 1:
            #仅运行一个进程
            # For the case where only one process is required.
            self._server = self.pool.spawn(self._run, application,
                                           self._socket)
            #知会systemd,本进程已完成启动
            systemd.notify_once()
        else:
            # Minimize the cost of checking for child exit by extending the
            # wait interval past the default of 0.01s.
            #多进程方式启动
            self._launcher = common_service.ProcessLauncher(CONF,
                                                            wait_interval=1.0)
            self._server = WorkerService(self, application)
            self._launcher.launch_service(self._server, workers=workers)
예제 #13
0
파일: api_cfn.py 프로젝트: aaratn/heat
def main():
    try:
        server = launch_cfn_api()
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #14
0
def main():
    try:
        server = launch_cfn_api()
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #15
0
 def wait(self, ready_callback=None):
     systemd.notify_once()
     while True:
         self.handle_signal()
         status, signo = self._wait_for_exit_or_signal(ready_callback)
         if not _is_sighup_and_daemon(signo):
             return status
         self.restart()
예제 #16
0
파일: all.py 프로젝트: noironetworks/heat
def main():
    try:
        threads = launch_all()
        services = [thread.wait() for thread in threads]
        systemd.notify_once()
        [service.wait() for service in services]
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #17
0
def main():
    try:
        threads = launch_all()
        services = [thread.wait() for thread in threads]
        systemd.notify_once()
        [service.wait() for service in services]
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #18
0
    def wait(self):
        systemd.notify_once()
        while True:
            self.handle_signal()
            status, signo = self._wait_for_exit_or_signal()
            if not service._is_sighup_and_daemon(signo):
                break
            self.restart()

        self.services.wait()
        return status
예제 #19
0
    def wait(self, ready_callback=None):
        """Wait for a service to terminate and restart it on SIGHUP.

        :returns: termination status
        """
        systemd.notify_once()
        while True:
            self.handle_signal()
            status, signo = self._wait_for_exit_or_signal(ready_callback)
            if not _is_sighup_and_daemon(signo):
                return status
            self.restart()
예제 #20
0
    def wait(self, ready_callback=None):
        """Wait for a service to terminate and restart it on SIGHUP.

        :returns: termination status
        """
        systemd.notify_once()
        while True:
            self.handle_signal()
            status, signo = self._wait_for_exit_or_signal(ready_callback)
            if not _is_sighup_and_daemon(signo):
                return status
            self.restart()
예제 #21
0
    def wait(self):
        """Wait for a service to terminate and restart it on SIGHUP.

        :returns: termination status
        """
        systemd.notify_once()
        self.signal_handler.clear()
        while True:
            self.handle_signal()
            status, signo = self._wait_for_exit_or_signal()
            if not _is_sighup_and_daemon(signo):
                break
            self.restart()

        super(ServiceLauncher, self).wait()
        return status
예제 #22
0
    def wait(self):
        """Wait for a service to terminate and restart it on SIGHUP.

        :returns: termination status
        """
        systemd.notify_once()
        self.signal_handler.clear()
        while True:
            self.handle_signal()
            status, signo = self._wait_for_exit_or_signal()
            if not _is_sighup_and_daemon(signo):
                break
            self.restart()

        super(ServiceLauncher, self).wait()
        return status
예제 #23
0
    def wait(self):
        """Loop waiting on children to die and respawning as necessary."""

        systemd.notify_once()
        if self.conf.log_options:
            LOG.debug('Full set of CONF:')
            self.conf.log_opt_values(LOG, logging.DEBUG)

        try:
            while True:
                self.handle_signal()
                self._respawn_children()
                # No signal means that stop was called.  Don't clean up here.
                if not self.sigcaught:
                    return

                signame = self.signal_handler.signals_to_name[self.sigcaught]
                LOG.info('Caught %s, stopping children', signame)
                if not _is_sighup_and_daemon(self.sigcaught):
                    break

                child_signal = signal.SIGTERM
                if self.restart_method == 'reload':
                    self.conf.reload_config_files()
                elif self.restart_method == 'mutate':
                    self.conf.mutate_config_files()
                    child_signal = signal.SIGHUP
                for service in set(
                    [wrap.service for wrap in self.children.values()]):
                    service.reset()

                for pid in self.children:
                    os.kill(pid, child_signal)

                self.running = True
                self.sigcaught = None
        except eventlet.greenlet.GreenletExit:
            LOG.info("Wait called after thread killed. Cleaning up.")

        # if we are here it means that we are trying to do graceful shutdown.
        # add alarm watching that graceful_shutdown_timeout is not exceeded
        if (self.conf.graceful_shutdown_timeout
                and self.signal_handler.is_signal_supported('SIGALRM')):
            signal.alarm(self.conf.graceful_shutdown_timeout)

        self.stop()
예제 #24
0
파일: wsgi.py 프로젝트: trozet/tacker
    def start(self, application, port, host="0.0.0.0", workers=0):
        """Run a WSGI server with the given application."""
        self._host = host
        self._port = port
        backlog = CONF.backlog

        self._socket = self._get_socket(self._host, self._port, backlog=backlog)
        if workers < 1:
            # For the case where only one process is required.
            self._server = self.pool.spawn(self._run, application, self._socket)
            systemd.notify_once()
        else:
            # Minimize the cost of checking for child exit by extending the
            # wait interval past the default of 0.01s.
            self._launcher = common_service.ProcessLauncher(CONF, wait_interval=1.0)
            self._server = WorkerService(self, application)
            self._launcher.launch_service(self._server, workers=workers)
예제 #25
0
파일: wsgi.py 프로젝트: Gin077/neutron
 def _launch(self, application, workers=0):
     service = WorkerService(self, application)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         service.start()
         systemd.notify_once()
     else:
         # dispose the whole pool before os.fork, otherwise there will
         # be shared DB connections in child processes which may cause
         # DB errors.
         api.dispose()
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(cfg.CONF,
                                                       wait_interval=1.0)
         self._server.launch_service(service, workers=workers)
예제 #26
0
 def _launch(self, application, workers=0):
     service = WorkerService(self, application)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         service.start()
         systemd.notify_once()
     else:
         # dispose the whole pool before os.fork, otherwise there will
         # be shared DB connections in child processes which may cause
         # DB errors.
         api.dispose()
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(cfg.CONF,
                                                       wait_interval=1.0)
         self._server.launch_service(service, workers=workers)
예제 #27
0
    def wait(self):
        """Loop waiting on children to die and respawning as necessary."""

        systemd.notify_once()
        if self.conf.log_options:
            LOG.debug('Full set of CONF:')
            self.conf.log_opt_values(LOG, logging.DEBUG)

        try:
            while True:
                self.handle_signal()
                self._respawn_children()
                # No signal means that stop was called.  Don't clean up here.
                if not self.sigcaught:
                    return

                signame = self.signal_handler.signals_to_name[self.sigcaught]
                LOG.info(_LI('Caught %s, stopping children'), signame)
                if not _is_sighup_and_daemon(self.sigcaught):
                    break

                if self.restart_method == 'reload':
                    self.conf.reload_config_files()
                elif self.restart_method == 'mutate':
                    self.conf.mutate_config_files()
                for service in set(
                        [wrap.service for wrap in self.children.values()]):
                    service.reset()

                for pid in self.children:
                    os.kill(pid, signal.SIGTERM)

                self.running = True
                self.sigcaught = None
        except eventlet.greenlet.GreenletExit:
            LOG.info(_LI("Wait called after thread killed. Cleaning up."))

        # if we are here it means that we are trying to do graceful shutdown.
        # add alarm watching that graceful_shutdown_timeout is not exceeded
        if (self.conf.graceful_shutdown_timeout and
                self.signal_handler.is_signal_supported('SIGALRM')):
            signal.alarm(self.conf.graceful_shutdown_timeout)

        self.stop()
예제 #28
0
def serve(*servers):
    if max([server[1].workers for server in servers]) > 1:
        launcher = service.ProcessLauncher(CONF)
    else:
        launcher = service.ServiceLauncher(CONF)

    for name, server in servers:
        try:
            server.launch_with(launcher)
        except socket.error:
            logging.exception("Failed to start the %(name)s server" %
                              {"name": name})
            raise

    # notify calling process we are ready to serve
    systemd.notify_once()

    for name, server in servers:
        launcher.wait()
예제 #29
0
def serve(*servers):
    if max([server[1].workers for server in servers]) > 1:
        # TODO(arosen) - need to provide way to communicate with DSE services
        launcher = service.ProcessLauncher(cfg.CONF)
    else:
        launcher = service.ServiceLauncher(cfg.CONF)

    for name, server in servers:
        try:
            server.launch_with(launcher)
        except socket.error:
            LOG.exception(_('Failed to start the %s server'), name)
            raise

    # notify calling process we are ready to serve
    systemd.notify_once()

    for name, server in servers:
        launcher.wait()
예제 #30
0
def serve(*servers):
    if max([server[1].workers for server in servers]) > 1:
        launcher = service.ProcessLauncher(CONF)
    else:
        launcher = service.ServiceLauncher(CONF)

    for name, server in servers:
        try:
            server.launch_with(launcher)
        except socket.error:
            logging.exception("Failed to start the %(name)s server" % {
                "name": name})
            raise

    # notify calling process we are ready to serve
    systemd.notify_once()

    for name, server in servers:
        launcher.wait()
예제 #31
0
def main():
    config.parse_args(sys.argv, 'senlin-api')
    logging.setup(CONF, 'senlin-api')
    gmr.TextGuruMeditation.setup_autorun(version)
    objects.register_all()
    messaging.setup()

    app = wsgi.load_paste_app()

    host = CONF.senlin_api.bind_host
    port = CONF.senlin_api.bind_port
    LOG.info('Starting Senlin API on %(host)s:%(port)s', {
        'host': host,
        'port': port
    })
    profiler.setup('senlin-api', host)
    server = wsgi.Server('senlin-api', CONF.senlin_api)
    server.start(app, default_port=port)
    systemd.notify_once()
    server.wait()
예제 #32
0
파일: api.py 프로젝트: openstack/bilean
def main():
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project='bilean', prog='bilean-api',
                 version=version.version_info.version_string())
        logging.setup(cfg.CONF, 'bilean-api')
        messaging.setup()

        app = config.load_paste_app()

        port = cfg.CONF.bilean_api.bind_port
        host = cfg.CONF.bilean_api.bind_host
        LOG.info(_LI('Starting Bilean ReST API on %(host)s:%(port)s'),
                 {'host': host, 'port': port})
        server = wsgi.Server('bilean-api', cfg.CONF.bilean_api)
        server.start(app, default_port=port)
        systemd.notify_once()
        server.wait()
    except RuntimeError as ex:
        sys.exit("ERROR: %s" % six.text_type(ex))
예제 #33
0
 def _launch(self, application, workers=0):
     service = WorkerService(self, application, self.disable_ssl, workers)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         # Dump the initial option values
         cfg.CONF.log_opt_values(LOG, logging.DEBUG)
         service.start()
         systemd.notify_once()
     else:
         # dispose the whole pool before os.fork, otherwise there will
         # be shared DB connections in child processes which may cause
         # DB errors.
         api.context_manager.dispose_pool()
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(cfg.CONF,
                                                       wait_interval=1.0)
         self._server.launch_service(service,
                                     workers=service.worker_process_count)
예제 #34
0
파일: wsgi.py 프로젝트: gotostack/neutron
 def _launch(self, application, workers=0):
     service = WorkerService(self, application, self.disable_ssl, workers)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         # Dump the initial option values
         cfg.CONF.log_opt_values(LOG, logging.DEBUG)
         service.start()
         systemd.notify_once()
     else:
         # dispose the whole pool before os.fork, otherwise there will
         # be shared DB connections in child processes which may cause
         # DB errors.
         api.context_manager.dispose_pool()
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(cfg.CONF,
                                                       wait_interval=1.0)
         self._server.launch_service(service,
                                     workers=service.worker_process_count)
예제 #35
0
def main():
    try:
        config.parse_args()
        wsgi.set_eventlet_hub()
        logging.setup(CONF, 'daisy')

        if cfg.CONF.profiler.enabled:
            _notifier = osprofiler.notifier.create("Messaging",
                                                   notifier.messaging, {},
                                                   notifier.get_transport(),
                                                   "daisy", "api",
                                                   cfg.CONF.bind_host)
            osprofiler.notifier.set(_notifier)
        else:
            osprofiler.web.disable()

        server = wsgi.Server()
        server.start(config.load_paste_app('daisy-api'), default_port=9292)
        systemd.notify_once()
        server.wait()
    except Exception as e:
        fail(e)
예제 #36
0
def main():
    try:
        config.parse_args()
        wsgi.set_eventlet_hub()
        logging.setup(CONF, 'daisy')

        if cfg.CONF.profiler.enabled:
            _notifier = osprofiler.notifier.create("Messaging",
                                                   notifier.messaging, {},
                                                   notifier.get_transport(),
                                                   "daisy", "api",
                                                   cfg.CONF.bind_host)
            osprofiler.notifier.set(_notifier)
        else:
            osprofiler.web.disable()

        server = wsgi.Server()
        server.start(config.load_paste_app('daisy-api'), default_port=9292)
        systemd.notify_once()
        server.wait()
    except Exception as e:
        fail(e)
예제 #37
0
파일: api.py 프로젝트: steveb/heat
def main():
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project="heat", prog="heat-api", version=version.version_info.version_string())
        logging.setup(cfg.CONF, "heat-api")
        config.set_config_defaults()
        messaging.setup()

        app = config.load_paste_app()

        port = cfg.CONF.heat_api.bind_port
        host = cfg.CONF.heat_api.bind_host
        LOG.info(_LI("Starting Heat REST API on %(host)s:%(port)s"), {"host": host, "port": port})
        profiler.setup("heat-api", host)
        gmr.TextGuruMeditation.setup_autorun(version)
        server = wsgi.Server("heat-api", cfg.CONF.heat_api)
        server.start(app, default_port=port)
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        msg = six.text_type(e)
        sys.exit("ERROR: %s" % msg)
예제 #38
0
def serve(*servers):
    logging.warning(_('Running keystone via eventlet is deprecated as of Kilo '
                      'in favor of running in a WSGI server (e.g. mod_wsgi). '
                      'Support for keystone under eventlet will be removed in '
                      'the "M"-Release.'))
    if max([server[1].workers for server in servers]) > 1:
        launcher = service.ProcessLauncher(CONF)
    else:
        launcher = service.ServiceLauncher(CONF)

    for name, server in servers:
        try:
            server.launch_with(launcher)
        except socket.error:
            logging.exception(_('Failed to start the %(name)s server') % {
                'name': name})
            raise

    # notify calling process we are ready to serve
    systemd.notify_once()

    for name, server in servers:
        launcher.wait()
예제 #39
0
def serve(*servers):
    logging.warning(_('Running keystone via eventlet is deprecated as of Kilo '
                      'in favor of running in a WSGI server (e.g. mod_wsgi). '
                      'Support for keystone under eventlet will be removed in '
                      'the "M"-Release.'))
    if max([server[1].workers for server in servers]) > 1:
        launcher = service.ProcessLauncher(CONF)
    else:
        launcher = service.ServiceLauncher(CONF)

    for name, server in servers:
        try:
            server.launch_with(launcher)
        except socket.error:
            logging.exception(_('Failed to start the %(name)s server') % {
                'name': name})
            raise

    # notify calling process we are ready to serve
    systemd.notify_once()

    for name, server in servers:
        launcher.wait()
예제 #40
0
def main():
    try:
        config.parse_args()
        wsgi.set_eventlet_hub()
        logging.setup(CONF, 'daisy')

        if cfg.CONF.profiler.enabled:
            _notifier = osprofiler.notifier.create("Messaging",
                                                   notifier.messaging, {},
                                                   notifier.get_transport(),
                                                   "daisy", "registry",
                                                   cfg.CONF.bind_host)
            osprofiler.notifier.set(_notifier)

        else:
            osprofiler.web.disable()

        server = wsgi.Server()
        server.start(config.load_paste_app('daisy-registry'),
                     default_port=9191)
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        sys.exit("ERROR: %s" % utils.exception_to_str(e))
예제 #41
0
def main():
    try:
        config.parse_args()
        wsgi.set_eventlet_hub()
        logging.setup(CONF, 'daisy')

        if cfg.CONF.profiler.enabled:
            _notifier = osprofiler.notifier.create("Messaging",
                                                   notifier.messaging, {},
                                                   notifier.get_transport(),
                                                   "daisy", "registry",
                                                   cfg.CONF.bind_host)
            osprofiler.notifier.set(_notifier)

        else:
            osprofiler.web.disable()

        server = wsgi.Server()
        server.start(config.load_paste_app('daisy-registry'),
                     default_port=9191)
        systemd.notify_once()
        server.wait()
    except RuntimeError as e:
        sys.exit("ERROR: %s" % utils.exception_to_str(e))
예제 #42
0
파일: main.py 프로젝트: ekasitk/sahara
def start_server(app):
    server = wsgi.Server()
    server.start(app)
    systemd.notify_once()
    server.wait()
예제 #43
0
파일: api.py 프로젝트: MountainWei/miper
from miper.common import rpc

_lazy.enable_lazy()

LOG = logging.getLogger('miper.api')

if __name__ == '__main__':
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project='miper', prog='miper-api',
                 version='0.0.2')
        logging.setup(cfg.CONF, 'miper-api')

        # messaging configuration
        rpc.set_defaults(control_exchange='miper')
        rpc.init(cfg.CONF)

        conf_file = os.path.join(possible_topdir, "etc", "api-paste.ini")
        app = deploy.loadapp("config:%s" % conf_file, 'main')

        host = cfg.CONF.miper_api.bind_host
        port = cfg.CONF.miper_api.bind_port
        LOG.info(_LI('Starting Miper API on %(host)s:%(port)s'),
                 {'host': host, 'port': port})
        server = wsgi.Server('miper-api', cfg.CONF.miper_api)
        server.start(app, default_port=port)
        systemd.notify_once()
        server.wait()
    except RuntimeError as ex:
        sys.exit("ERROR: %s" % six.text_type(ex))
예제 #44
0
파일: main.py 프로젝트: rogeryu27/sahara
def start_server(app):
    server = wsgi.Server()
    server.start(app)
    systemd.notify_once()
    server.wait()