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
- 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
- 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
$ python3 setup.py install
$ gns3server
.. code:: bash
cd gns3-server-master
sudo python3 setup.py install
gns3server
Windows
-------

View File

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

View File

@ -21,7 +21,8 @@ import sys
import multiprocessing
import logging
import tornado.options
import gns3server
from .server import Server
from .version import __version__
# command line options
from tornado.options import define
@ -40,7 +41,7 @@ def main():
multiprocessing.freeze_support()
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))
# we only support Python 2 version >= 2.7 and Python 3 version >= 3.3
@ -59,9 +60,9 @@ def main():
logging.basicConfig(level=logging.INFO)
from tornado.options import options
server = gns3server.Server(options.host,
options.port,
ipc=options.ipc)
server = Server(options.host,
options.port,
ipc=options.ipc)
server.load_modules()
server.run()

View File

@ -194,6 +194,14 @@ class Server(object):
log.info("ZeroMQ server listening to 127.0.0.1:{}".format(self._zmq_port))
return router
def _shutdown(self):
"""
Shutdowns the I/O loop.
"""
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.stop()
def _cleanup(self, stop=True):
"""
Shutdowns any running module processes
@ -210,13 +218,6 @@ class Server(object):
module.terminate()
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:
ioloop.stop()
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.add_callback_from_signal(self._shutdown)