1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Return exit status 1 if server fails to start. Fixes #1744

This commit is contained in:
grossmj 2020-04-28 14:39:28 +09:30
parent 8536af33da
commit 72c6f5b484
2 changed files with 11 additions and 9 deletions

View File

@ -259,8 +259,9 @@ def run():
port = int(server_config["port"]) port = int(server_config["port"])
server = WebServer.instance(host, port) server = WebServer.instance(host, port)
status = 0
try: try:
server.run() status = server.run()
except OSError as e: except OSError as e:
# This is to ignore OSError: [WinError 0] The operation completed successfully exception on Windows. # This is to ignore OSError: [WinError 0] The operation completed successfully exception on Windows.
if not sys.platform.startswith("win") and not e.winerror == 0: if not sys.platform.startswith("win") and not e.winerror == 0:
@ -269,7 +270,7 @@ def run():
log.critical("Critical error while running the server: {}".format(e), exc_info=1) log.critical("Critical error while running the server: {}".format(e), exc_info=1)
CrashReport.instance().capture_exception() CrashReport.instance().capture_exception()
return return
finally:
if args.pid: if args.pid:
log.info("Remove PID file %s", args.pid) log.info("Remove PID file %s", args.pid)
try: try:

View File

@ -296,7 +296,7 @@ class WebServer:
self._handler = self._app.make_handler() self._handler = self._app.make_handler()
if self._run_application(self._handler, ssl_context) is False: if self._run_application(self._handler, ssl_context) is False:
self._loop.stop() self._loop.stop()
return sys.exit(1)
self._signal_handling() self._signal_handling()
self._exit_handling() self._exit_handling()
@ -317,3 +317,4 @@ class WebServer:
self._loop.run_until_complete(self.shutdown_server()) self._loop.run_until_complete(self.shutdown_server())
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass