From 8d471a89a85c0937ec748d96616880b292420aaf Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Feb 2015 15:56:10 -0700 Subject: [PATCH] Check for OSError when starting the server. --- gns3server/main.py | 2 +- gns3server/server.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gns3server/main.py b/gns3server/main.py index f400f8cd..f94c8e40 100644 --- a/gns3server/main.py +++ b/gns3server/main.py @@ -79,7 +79,7 @@ def parse_arguments(): parser.add_argument("--ssl", action="store_true", help="run in SSL mode") parser.add_argument("--certfile", help="SSL cert file", default="") parser.add_argument("--certkey", help="SSL key file", default="") - parser.add_argument("-L", "--local", action="store_true", help="local mode (allow some insecure operations)") + parser.add_argument("-L", "--local", action="store_true", help="local mode (allows some insecure operations)") parser.add_argument("-A", "--allow", action="store_true", help="allow remote connections to local console ports") parser.add_argument("-q", "--quiet", action="store_true", help="do not show logs on stdout") parser.add_argument("-d", "--debug", action="store_true", help="show debug logs and enable code live reload") diff --git a/gns3server/server.py b/gns3server/server.py index 00cd83bf..0ae237c1 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -53,7 +53,12 @@ class Server: @asyncio.coroutine def _run_application(self, app, ssl_context=None): - server = yield from self._loop.create_server(app.make_handler(), self._host, self._port, ssl=ssl_context) + try: + server = yield from self._loop.create_server(app.make_handler(), self._host, self._port, ssl=ssl_context) + except OSError as e: + log.critical("Could not start the server: {}".format(e)) + self._loop.stop() + return return server def _stop_application(self):