예제 #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 _setup_container(self, debug):
        self.container = create_container(self.config)
        self.container.debug = debug
        # Set global exception hook to send unhandled exception to the container's error_hook.
        sys.excepthook = self.container.excepthook

        install_plugins(self.container, self.config.get('plugins', {}))
        install_interfaces(self.container, self.config.get('interfaces', {}))

        for cls_name in self.args.get('--interface', ()):
            cls = import_object(cls_name)
            self.container.install_interface(cls)
예제 #3
0
파일: service.py 프로젝트: Xooxy/lymph
    def _setup_container(self, debug):
        self.container = create_container(self.config)
        self.container.debug = debug
        # Set global exception hook to send unhandled exception to the container's error_hook.
        sys.excepthook = self.container.excepthook

        install_plugins(self.container, self.config.get('plugins', {}))
        install_interfaces(self.container, self.config.get('interfaces', {}))

        for cls_name in self.args.get('--interface', ()):
            cls = import_object(cls_name)
            self.container.install_interface(cls)
예제 #4
0
파일: client.py 프로젝트: emulbreh/lymph
 def from_config(cls, config, **kwargs):
     interface_cls = kwargs.pop('interface_cls', ClientInterface)
     container = create_container(config)
     client = cls(container, interface_cls)
     container.start(register=False)
     return client
예제 #5
0
파일: client.py 프로젝트: torte/lymph
 def from_config(cls, config, **kwargs):
     interface_cls = kwargs.pop('interface_cls', ClientInterface)
     container = create_container(config)
     client = cls(container, interface_cls)
     container.start(register=False)
     return client