mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Return exit status 1 if server fails to start. Fixes #1744
This commit is contained in:
parent
8536af33da
commit
72c6f5b484
@ -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,10 +270,10 @@ 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:
|
||||||
os.remove(args.pid)
|
os.remove(args.pid)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.critical("Can't remove pid file %s: %s", args.pid, str(e))
|
log.critical("Can't remove pid file %s: %s", args.pid, str(e))
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user