diff --git a/pox/core.py b/pox/core.py index 5fd052773..6fb7b137e 100644 --- a/pox/core.py +++ b/pox/core.py @@ -28,6 +28,7 @@ class (an instance of which is available as pox.core.core). import inspect import time import os +import signal _path = inspect.stack()[0][1] _ext_path = _path[0:_path.rindex(os.sep)] @@ -152,6 +153,10 @@ def __init__ (self, name, component): self.name = name self.component = component +class RereadConfiguration (Event): + """ Fired when modules should reread their configuration files. """ + pass + import pox.lib.recoco as recoco class POXCore (EventMixin): @@ -179,7 +184,8 @@ class POXCore (EventMixin): DownEvent, GoingUpEvent, GoingDownEvent, - ComponentRegistered + ComponentRegistered, + RereadConfiguration ]) version = (0,3,0) @@ -317,6 +323,15 @@ def _get_platform_info (self): except: return "Unknown Platform" + def _add_signal_handlers (self): + try: + signal.signal(signal.SIGHUP, self._handler_signal_SIGHUP) + except ValueError: + log.warn('failed to install handler SIGHUP') + + def _handler_signal_SIGHUP (self, signal, frame): + self.raiseLater(core, RereadConfiguration) + def goUp (self): log.debug(self.version_string + " going up...") @@ -337,6 +352,8 @@ def goUp (self): self.starting_up = False self.raiseEvent(GoingUpEvent()) + self._add_signal_handlers() + self.raiseEvent(UpEvent()) self._waiter_notify()