mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Update the way we start controller to avoid hiding crash reports
This commit is contained in:
parent
cb02046e01
commit
9a632fb823
@ -79,7 +79,8 @@ class WebServer:
|
||||
|
||||
def _run_application(self, handler, ssl_context=None):
|
||||
try:
|
||||
self._server = self._loop.run_until_complete(self._loop.create_server(handler, self._host, self._port, ssl=ssl_context))
|
||||
srv = self._loop.create_server(handler, self._host, self._port, ssl=ssl_context)
|
||||
self._server, startup_res = self._loop.run_until_complete(asyncio.gather(srv, self._app.startup(), loop=self._loop))
|
||||
except OSError as e:
|
||||
log.critical("Could not start the server: {}".format(e))
|
||||
return False
|
||||
@ -249,6 +250,13 @@ class WebServer:
|
||||
time.sleep(1) # this is to prevent too many request to slow down the server
|
||||
log.debug("UDP server discovery stopped")
|
||||
|
||||
@asyncio.coroutine
|
||||
def _on_startup(self, *args):
|
||||
"""
|
||||
Called when the HTTP server start
|
||||
"""
|
||||
yield from Controller.instance().start()
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Starts the server.
|
||||
@ -284,6 +292,9 @@ class WebServer:
|
||||
log.debug("ENV %s=%s", key, val)
|
||||
|
||||
self._app = aiohttp.web.Application()
|
||||
# Background task started with the server
|
||||
self._app.on_startup.append(self._on_startup)
|
||||
|
||||
# Allow CORS for this domains
|
||||
cors = aiohttp_cors.setup(self._app, defaults={
|
||||
# Default web server for web gui dev
|
||||
@ -311,8 +322,6 @@ class WebServer:
|
||||
self._signal_handling()
|
||||
self._exit_handling()
|
||||
|
||||
controller_start = asyncio.async(Controller.instance().start())
|
||||
|
||||
if server_config.getboolean("shell"):
|
||||
asyncio.async(self.start_shell())
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
jsonschema>=2.4.0
|
||||
aiohttp>=1.1.3
|
||||
aiohttp>=1.1.6
|
||||
aiohttp_cors>=0.4.0
|
||||
yarl>=0.7.0
|
||||
Jinja2>=2.7.3
|
||||
|
Loading…
Reference in New Issue
Block a user