예제 #1
0
    def run(self):
        container = create_container(self.config)
        install_plugins(container, self.config.get('plugins', {}))
        install_interfaces(container, self.config.get('interfaces', {}))

        for cls_name in self.args.get('--interface', ()):
            cls = import_object(cls_name)
            container.install(cls)

        if self.args.get('--debug'):
            from gevent.backdoor import BackdoorServer
            backdoor = BackdoorServer(('127.0.0.1', 5005), locals={'container': container})
            gevent.spawn(backdoor.serve_forever)

        def handle_signal():
            logger.info('caught SIGINT/SIGTERM, pid=%s', os.getpid())
            container.stop()
            container.join()
            sys.exit(0)
        gevent.signal(signal.SIGINT, handle_signal)
        gevent.signal(signal.SIGTERM, handle_signal)

        setproctitle('lymph-instance (identity: %s, endpoint: %s, config: %s)' % (
            container.identity,
            container.endpoint,
            self.config.source,
        ))

        container.start(register=not self.args.get('--isolated', False))

        if self.args.get('--reload'):
            set_source_change_callback(container.stop)

        container.join()
예제 #2
0
    def run(self):
        debug = self.args.get('--debug')

        self._setup_container(debug)

        if debug:
            self._start_backdoor_terminal()

        self._register_signals()

        self.container.start(register=not self.args.get('--isolated', False))

        self._set_process_title()

        if self.args.get('--reload'):
            set_source_change_callback(self.container.stop)

        self.container.join()
예제 #3
0
파일: service.py 프로젝트: Xooxy/lymph
    def run(self):
        debug = self.args.get('--debug')

        self._setup_container(debug)

        if debug:
            self._start_backdoor_terminal()

        self._register_signals()

        self._set_process_title()

        self.container.start(register=not self.args.get('--isolated', False))

        if self.args.get('--reload'):
            set_source_change_callback(self.container.stop)

        self.container.join()
예제 #4
0
    def run(self):
        debug = self.args.get('--debug')
        loglevel = self.args.get('--loglevel', 'ERROR')

        self._setup_container(debug, loglevel)

        if debug:
            self._start_backdoor_terminal()

        self._register_signals()

        # set process title early since start() may take some time,
        # even though endpoint may not be known yet
        self._set_process_title()

        self.container.start(register=not self.args.get('--isolated', False))

        self._set_process_title()

        if self.args.get('--reload'):
            set_source_change_callback(self.container.stop)

        self.container.join()