def onJoin(self, details, publish_ready=True): """ Called when worker process has joined the node's management realm. """ yield NativeProcessSession.onJoin(self, details) procs = [ 'get_cpu_affinity', 'set_cpu_affinity', 'get_pythonpath', 'add_pythonpath', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) if self.debug: log.msg("Registering procedure '{}'".format(uri)) dl.append( self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) if self.debug: log.msg("{} registered {} procedures".format( self.__class__.__name__, len(regs))) if publish_ready: yield self.publish_ready()
def onJoin(self, details, publish_ready=True): """ Called when worker process has joined the node's management realm. """ yield NativeProcessSession.onJoin(self, details) procs = [ # CPU affinity for this worker process 'get_cpu_affinity', 'set_cpu_affinity', # PYTHONPATH used for this worker 'get_pythonpath', 'add_pythonpath', # profiling control 'get_profilers', 'start_profiler', 'query_profile', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.debug("Registering management API procedure {proc}", proc=uri) dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) if publish_ready: yield self.publish_ready()
def onJoin(self, details, publish_ready = True): """ Called when worker process has joined the node's management realm. """ yield NativeProcessSession.onJoin(self, details) procs = [ 'get_cpu_affinity', 'set_cpu_affinity', 'get_pythonpath', 'add_pythonpath', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) if self.debug: log.msg("Registering procedure '{}'".format(uri)) dl.append(self.register(getattr(self, proc), uri, options = RegisterOptions(details_arg = 'details', discloseCaller = True))) regs = yield DeferredList(dl) if self.debug: log.msg("{} registered {} procedures".format(self.__class__.__name__, len(regs))) if publish_ready: yield self.publish_ready()
def onJoin(self, details): # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): id = res['id'] if id in self._workers: ready = self._workers[id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(id) else: log.msg( "INTERNAL ERROR: on_worker_ready() fired for process {} - ready already called" .format(id)) else: log.msg( "INTERNAL ERROR: on_worker_ready() fired for process {} - no process with that ID" .format(id)) self.subscribe( on_worker_ready, 'crossbar.node.{}.on_worker_ready'.format(self._node_id)) yield NativeProcessSession.onJoin(self, details) # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>' # procs = [ 'shutdown', 'start_management_transport', 'get_info', 'get_workers', 'get_worker_log', 'start_router', 'stop_router', 'start_container', 'stop_container', 'start_guest', 'stop_guest', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) if self.debug: log.msg("Registering procedure '{}'".format(uri)) dl.append( self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) if self.debug: log.msg("{} registered {} procedures".format( self.__class__.__name__, len(regs)))
def onJoin(self, details): self.log.info("Joined realm '{realm}' on node management router", realm=details.realm) # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): id = res['id'] if id in self._workers: ready = self._workers[id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(id) else: self.log.error("Internal error: on_worker_ready() fired for process {process}, but already called earlier", process=id) else: self.log.error("Internal error: on_worker_ready() fired for process {process}, but no process with that ID", process=id) self.subscribe(on_worker_ready, 'crossbar.node.{}.on_worker_ready'.format(self._node_id)) yield NativeProcessSession.onJoin(self, details) # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>' # procs = [ 'shutdown', 'get_info', 'get_workers', 'get_worker_log', 'start_router', 'stop_router', 'start_container', 'stop_container', 'start_guest', 'stop_guest', 'start_websocket_testee', 'stop_websocket_testee', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.debug("Registering management API procedure {proc}", proc=uri) dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) self._started = utcnow() self.publish(u"crossbar.node.on_ready", self._node_id) self.log.debug("Node controller ready")
def onJoin(self, details): self.log.info("Joined realm '{realm}' on node management router", realm=details.realm) # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): id = res['id'] if id in self._workers: ready = self._workers[id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(id) else: self.log.error("Internal error: on_worker_ready() fired for process {process}, but already called earlier", process=id) else: self.log.error("Internal error: on_worker_ready() fired for process {process}, but no process with that ID", process=id) self.subscribe(on_worker_ready, 'crossbar.node.{}.on_worker_ready'.format(self._node_id)) yield NativeProcessSession.onJoin(self, details) # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>' # procs = [ 'shutdown', 'get_info', 'get_workers', 'get_worker_log', 'start_router', 'stop_router', 'start_container', 'stop_container', 'start_guest', 'stop_guest', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.debug("Registering management API procedure {proc}", proc=uri) dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) self._started = utcnow() self.publish(u"crossbar.node.on_ready", self._node_id) self.log.debug("Node controller ready")
def onJoin(self, details): from autobahn.wamp.types import SubscribeOptions self.log.info("Joined realm '{realm}' on node management router", realm=details.realm) # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): id = res['id'] if id in self._workers: ready = self._workers[id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(id) else: self.log.error( "Internal error: on_worker_ready() fired for process {process}, but already called earlier", process=id) else: self.log.error( "Internal error: on_worker_ready() fired for process {process}, but no process with that ID", process=id) self.subscribe(on_worker_ready, u'crossbar.worker..on_worker_ready', SubscribeOptions(match=u'wildcard')) yield NativeProcessSession.onJoin(self, details) # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>' # dl = [] for proc in self.PROCS: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.info('Registering management API procedure "{proc}"', proc=uri) dl.append( self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) self._started = utcnow() self.publish(u"crossbar.on_ready") self.log.debug("Node controller ready")
def onJoin(self, details): # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): id = res['id'] if id in self._workers: ready = self._workers[id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(id) else: self.log.error("INTERNAL ERROR: on_worker_ready() fired for process {process} - ready already called", process=id) else: self.log.error("INTERNAL ERROR: on_worker_ready() fired for process {process} - no process with that ID", process=id) self.subscribe(on_worker_ready, 'crossbar.node.{}.on_worker_ready'.format(self._node_id)) yield NativeProcessSession.onJoin(self, details) # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>' # procs = [ 'shutdown', 'start_management_transport', 'get_info', 'get_workers', 'get_worker_log', 'start_router', 'stop_router', 'start_container', 'stop_container', 'start_guest', 'stop_guest', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.debug("Registering procedure '{uri}'", uri=uri) dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("{me} registered {registers} procedures", me=self.__class__.__name__, registers=len(regs))
def onJoin(self, details, publish_ready=True): """ Called when worker process has joined the node's management realm. """ yield NativeProcessSession.onJoin(self, details) procs = [ # orderly shutdown worker "from inside" 'shutdown', # CPU affinity for this worker process 'get_cpu_count', 'get_cpu_affinity', 'set_cpu_affinity', # PYTHONPATH used for this worker 'get_pythonpath', 'add_pythonpath', # profiling control 'get_profilers', 'start_profiler', 'get_profile', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.debug("Registering management API procedure {proc}", proc=uri) dl.append( self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) # setup SIGTERM handler to orderly shutdown the worker def shutdown(sig, frame): self.log.warn("Native worker received SIGTERM - shutting down ..") self.shutdown() signal.signal(signal.SIGTERM, shutdown) # the worker is ready for work! if publish_ready: yield self.publish_ready()
def onJoin(self, details): from autobahn.wamp.types import SubscribeOptions self.log.debug("Joined realm '{realm}' on node management router", realm=details.realm) # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): worker_id = res['id'] if worker_id in self._workers: ready = self._workers[worker_id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(worker_id) else: self.log.error( "Internal error: on_worker_ready() fired for process {process}, but already called earlier", process=worker_id) else: self.log.error( "Internal error: on_worker_ready() fired for process {process}, but no process with that ID", process=worker_id) self.subscribe(on_worker_ready, u'crossbar.worker..on_worker_ready', SubscribeOptions(match=u'wildcard')) yield NativeProcessSession.onJoin(self, details) # above upcall registers procedures we have marked with @wamp.register(None) # we need to catch SIGINT here to properly shutdown the # node explicitly (a Twisted system trigger wouldn't allow us to distinguish # different reasons/origins of exiting ..) def signal_handler(signal, frame): # the following will shutdown the Twisted reactor in the end self.shutdown() signal.signal(signal.SIGINT, signal_handler) self._started = utcnow() self.publish(u"crossbar.on_ready") self.log.debug("Node controller ready")
def onJoin(self, details, publish_ready=True): """ Called when worker process has joined the node's management realm. """ yield NativeProcessSession.onJoin(self, details) # above upcall registers all our "@wamp.register(None)" methods # setup SIGTERM handler to orderly shutdown the worker def shutdown(sig, frame): self.log.warn("Native worker received SIGTERM - shutting down ..") self.shutdown() signal.signal(signal.SIGTERM, shutdown) # the worker is ready for work! if publish_ready: yield self.publish_ready()
def onJoin(self, details, publish_ready=True): """ Called when worker process has joined the node's management realm. """ yield NativeProcessSession.onJoin(self, details) procs = [ # orderly shutdown worker "from inside" 'shutdown', # CPU affinity for this worker process 'get_cpu_count', 'get_cpu_affinity', 'set_cpu_affinity', # PYTHONPATH used for this worker 'get_pythonpath', 'add_pythonpath', # profiling control 'get_profilers', 'start_profiler', 'get_profile', ] dl = [] for proc in procs: uri = '{}.{}'.format(self._uri_prefix, proc) self.log.debug("Registering management API procedure {proc}", proc=uri) dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) # setup SIGTERM handler to orderly shutdown the worker def shutdown(sig, frame): self.log.warn("Native worker received SIGTERM - shutting down ..") self.shutdown() signal.signal(signal.SIGTERM, shutdown) # the worker is ready for work! if publish_ready: yield self.publish_ready()
def onJoin(self, details): from autobahn.wamp.types import SubscribeOptions self.log.debug("Joined realm '{realm}' on node management router", realm=details.realm) # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): worker_id = res['id'] if worker_id in self._workers: ready = self._workers[worker_id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(worker_id) else: self.log.error("Internal error: on_worker_ready() fired for process {process}, but already called earlier", process=worker_id) else: self.log.error("Internal error: on_worker_ready() fired for process {process}, but no process with that ID", process=worker_id) self.subscribe(on_worker_ready, u'crossbar.worker..on_worker_ready', SubscribeOptions(match=u'wildcard')) yield NativeProcessSession.onJoin(self, details) # above upcall registers procedures we have marked with @wamp.register(None) # we need to catch SIGINT here to properly shutdown the # node explicitly (a Twisted system trigger wouldn't allow us to distinguish # different reasons/origins of exiting ..) def signal_handler(signal, frame): # the following will shutdown the Twisted reactor in the end self.shutdown() signal.signal(signal.SIGINT, signal_handler) self._started = utcnow() self.publish(u"crossbar.on_ready") self.log.debug("Node controller ready")
def onJoin(self, details): from autobahn.wamp.types import SubscribeOptions self.log.debug("Joined realm '{realm}' on node management router", realm=details.realm) # When a (native) worker process has connected back to the router of # the node controller, the worker will publish this event # to signal it's readyness. # def on_worker_ready(res): id = res['id'] if id in self._workers: ready = self._workers[id].ready if not ready.called: # fire the Deferred previously stored for # signaling "worker ready" ready.callback(id) else: self.log.error( "Internal error: on_worker_ready() fired for process {process}, but already called earlier", process=id) else: self.log.error( "Internal error: on_worker_ready() fired for process {process}, but no process with that ID", process=id) self.subscribe(on_worker_ready, u'crossbar.worker..on_worker_ready', SubscribeOptions(match=u'wildcard')) yield NativeProcessSession.onJoin(self, details) # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>' # dl = [] for proc in self.PROCS: uri = u'{}.{}'.format(self._uri_prefix, proc) self.log.debug('Registering management API procedure "{proc}"', proc=uri) dl.append( self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details'))) regs = yield DeferredList(dl) self.log.debug("Registered {cnt} management API procedures", cnt=len(regs)) # we need to catch SIGINT here to properly shutdown the # node explicitly (a Twisted system trigger wouldn't allow us to distinguish # different reasons/origins of exiting ..) def signal_handler(signal, frame): # the following will shutdown the Twisted reactor in the end self.shutdown() signal.signal(signal.SIGINT, signal_handler) self._started = utcnow() self.publish(u"crossbar.on_ready") self.log.debug("Node controller ready")