diff --git a/gns3server/handlers/jsonrpc_websocket.py b/gns3server/handlers/jsonrpc_websocket.py index acc56893..32f8c9da 100644 --- a/gns3server/handlers/jsonrpc_websocket.py +++ b/gns3server/handlers/jsonrpc_websocket.py @@ -140,6 +140,11 @@ class JSONRPCWebSocket(tornado.websocket.WebSocketHandler): # This is a notification, silently ignore this error... return + if method.startswith("builtin"): + log.info("calling built-in method {}".format(method)) + self.destinations[method]() + return + module = self.destinations[method] # ZMQ requests are encoded in JSON # format is a JSON array: [session ID, JSON-RPC request] diff --git a/gns3server/modules/base.py b/gns3server/modules/base.py index 7cece337..70c45cd9 100644 --- a/gns3server/modules/base.py +++ b/gns3server/modules/base.py @@ -113,6 +113,8 @@ class IModule(multiprocessing.Process): signals = [signal.SIGTERM, signal.SIGINT] if not sys.platform.startswith("win"): signals.extend([signal.SIGHUP, signal.SIGQUIT]) + else: + signals.extend([signal.SIGBREAK]) for sig in signals: signal.signal(sig, signal_handler) diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 9dd43667..dc8bdc6c 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -127,6 +127,8 @@ class Dynamips(IModule): Properly stops the module. """ + #if not sys.platform.startswith("win32"): + # self._callback.stop() if self._hypervisor_manager: self._hypervisor_manager.stop_all_hypervisors() IModule.stop(self) # this will stop the I/O loop diff --git a/gns3server/modules/iou/__init__.py b/gns3server/modules/iou/__init__.py index 9ab032a1..49f62864 100644 --- a/gns3server/modules/iou/__init__.py +++ b/gns3server/modules/iou/__init__.py @@ -95,6 +95,7 @@ class IOU(IModule): Properly stops the module. """ + #self._iou_callback.stop() # delete all IOU instances for iou_id in self._iou_instances: iou_instance = self._iou_instances[iou_id] diff --git a/gns3server/server.py b/gns3server/server.py index 990fe380..f7255dc3 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -107,6 +107,9 @@ class Server(object): # instance.start() # starts the new process #======================================================================= + # special built-in destination to stop the server + JSONRPCWebSocket.register_destination("builtin.stop", self._cleanup) + for module in MODULES: instance = module(module.__name__.lower(), "127.0.0.1", # ZeroMQ server address @@ -151,6 +154,8 @@ class Server(object): signals = [signal.SIGTERM, signal.SIGINT] if not sys.platform.startswith("win"): signals.extend([signal.SIGHUP, signal.SIGQUIT]) + else: + signals.extend([signal.SIGBREAK]) for sig in signals: signal.signal(sig, signal_handler)