mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-20 03:36:23 +00:00
Support for cooperative signal handling of uvicorn v0.29.0
This commit is contained in:
parent
fd60bda2c2
commit
9b66d939d2
@ -29,6 +29,7 @@ import gns3server.utils.get_resource
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
def daemonize():
|
def daemonize():
|
||||||
@ -70,7 +71,10 @@ def main():
|
|||||||
daemonize()
|
daemonize()
|
||||||
from gns3server.server import Server
|
from gns3server.server import Server
|
||||||
|
|
||||||
Server().run()
|
try:
|
||||||
|
asyncio.run(Server().run())
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -239,7 +239,7 @@ class Server:
|
|||||||
log.critical("Can't write pid file %s: %s", path, str(e))
|
log.critical("Can't write pid file %s: %s", path, str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def run(self):
|
async def run(self):
|
||||||
|
|
||||||
args = self._parse_arguments(sys.argv[1:])
|
args = self._parse_arguments(sys.argv[1:])
|
||||||
|
|
||||||
@ -333,8 +333,7 @@ class Server:
|
|||||||
uvicorn_logger.propagate = False
|
uvicorn_logger.propagate = False
|
||||||
|
|
||||||
server = uvicorn.Server(config)
|
server = uvicorn.Server(config)
|
||||||
loop = asyncio.get_event_loop()
|
await server.serve()
|
||||||
loop.run_until_complete(server.serve())
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.critical(f"Critical error while running the server: {e}", exc_info=1)
|
log.critical(f"Critical error while running the server: {e}", exc_info=1)
|
||||||
|
Loading…
Reference in New Issue
Block a user