Skip to content

Commit

Permalink
Support for cooperative signal handling of uvicorn v0.29.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Apr 3, 2024
1 parent fd60bda commit 9b66d93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion gns3server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import os
import sys
import asyncio


def daemonize():
Expand Down Expand Up @@ -70,7 +71,10 @@ def main():
daemonize()
from gns3server.server import Server

Server().run()
try:
asyncio.run(Server().run())
except KeyboardInterrupt:
pass


if __name__ == "__main__":
Expand Down
5 changes: 2 additions & 3 deletions gns3server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def _pid_lock(path):
log.critical("Can't write pid file %s: %s", path, str(e))
sys.exit(1)

def run(self):
async def run(self):

args = self._parse_arguments(sys.argv[1:])

Expand Down Expand Up @@ -333,8 +333,7 @@ def run(self):
uvicorn_logger.propagate = False

server = uvicorn.Server(config)
loop = asyncio.get_event_loop()
loop.run_until_complete(server.serve())
await server.serve()

except Exception as e:
log.critical(f"Critical error while running the server: {e}", exc_info=1)
Expand Down

0 comments on commit 9b66d93

Please sign in to comment.