mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Catch SIGTERM, SIGINT, SIGHUP and SIGQUIT to properly shutdown the
server.
This commit is contained in:
1 parent
2f23a092e3
commit
798f0367b9
3 files changed
+10
-1
No files matched your search
@@ -89,6 +89,7 @@ class IModule(multiprocessing.Process):
|
||||
Starts the event loop
|
||||
"""
|
||||
|
||||
log.info("{} module running with PID {}".format(self.name, self.pid))
|
||||
self._setup()
|
||||
try:
|
||||
self._ioloop.start()
|
||||
|
||||
@@ -24,6 +24,7 @@ from zmq.eventloop import ioloop, zmqstream
|
||||
ioloop.install()
|
||||
|
||||
import os
|
||||
import signal
|
||||
import errno
|
||||
import functools
|
||||
import socket
|
||||
@@ -94,6 +95,13 @@ class Server(object):
|
||||
stream.on_recv(StompWebSocket.dispatch_message)
|
||||
tornado.autoreload.add_reload_hook(functools.partial(self._cleanup, stop=False))
|
||||
|
||||
def signal_handler(signum=None, frame=None):
|
||||
log.warning("Got signal {}, exiting...".format(signum))
|
||||
self._cleanup()
|
||||
|
||||
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
|
||||
signal.signal(sig, signal_handler)
|
||||
|
||||
try:
|
||||
ioloop.start()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
|
||||
Reference in new issue
Block a user