Tornado graceful shutdown.

Update the README.
This commit is contained in:
grossmj 2014-04-02 10:33:35 -06:00
parent a92da02973
commit 20597e29df
4 changed files with 24 additions and 18 deletions

View File

@ -15,12 +15,16 @@ Dependencies:
- Python version 3.3 or above - Python version 3.3 or above
- pip & setuptools must be installed, please see http://pip.readthedocs.org/en/latest/installing.html - pip & setuptools must be installed, please see http://pip.readthedocs.org/en/latest/installing.html
(or sudo apt-get install python3-pip but install more packages)
- pyzmq, to install: sudo apt-get install python3-zmq or pip3 install pyzmq - pyzmq, to install: sudo apt-get install python3-zmq or pip3 install pyzmq
- tornado, to install: sudo apt-get install python3-tornado or pip3 install tornado - tornado, to install: sudo apt-get install python3-tornado or pip3 install tornado
- netifaces (optional), to install: sudo apt-get install python3-netifaces or pip3 install netifaces-py3 - netifaces (optional), to install: sudo apt-get install python3-netifaces or pip3 install netifaces-py3
$ python3 setup.py install .. code:: bash
$ gns3server
cd gns3-server-master
sudo python3 setup.py install
gns3server
Windows Windows
------- -------

View File

@ -23,6 +23,6 @@
# or negative for a release candidate or beta (after the base version # or negative for a release candidate or beta (after the base version
# number has been incremented) # number has been incremented)
from .module_manager import ModuleManager #from .module_manager import ModuleManager
from .server import Server #from .server import Server
from .version import __version__ from .version import __version__

View File

@ -21,7 +21,8 @@ import sys
import multiprocessing import multiprocessing
import logging import logging
import tornado.options import tornado.options
import gns3server from .server import Server
from .version import __version__
# command line options # command line options
from tornado.options import define from tornado.options import define
@ -40,7 +41,7 @@ def main():
multiprocessing.freeze_support() multiprocessing.freeze_support()
current_year = datetime.date.today().year current_year = datetime.date.today().year
print("GNS3 server version {}".format(gns3server.__version__)) print("GNS3 server version {}".format(__version__))
print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year))
# we only support Python 2 version >= 2.7 and Python 3 version >= 3.3 # we only support Python 2 version >= 2.7 and Python 3 version >= 3.3
@ -59,7 +60,7 @@ def main():
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
from tornado.options import options from tornado.options import options
server = gns3server.Server(options.host, server = Server(options.host,
options.port, options.port,
ipc=options.ipc) ipc=options.ipc)
server.load_modules() server.load_modules()

View File

@ -194,6 +194,14 @@ class Server(object):
log.info("ZeroMQ server listening to 127.0.0.1:{}".format(self._zmq_port)) log.info("ZeroMQ server listening to 127.0.0.1:{}".format(self._zmq_port))
return router return router
def _shutdown(self):
"""
Shutdowns the I/O loop.
"""
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.stop()
def _cleanup(self, stop=True): def _cleanup(self, stop=True):
""" """
Shutdowns any running module processes Shutdowns any running module processes
@ -210,13 +218,6 @@ class Server(object):
module.terminate() module.terminate()
module.join(timeout=1) module.join(timeout=1)
ioloop = tornado.ioloop.IOLoop.instance()
# close any fd that would have remained open...
for fd in ioloop._handlers.keys():
try:
os.close(fd)
except Exception:
pass
if stop: if stop:
ioloop.stop() ioloop = tornado.ioloop.IOLoop.instance()
ioloop.add_callback_from_signal(self._shutdown)