Add some backup checks when stopping maubot
This commit is contained in:
parent
20a9ca6aa6
commit
6f2162d5f3
@ -90,7 +90,10 @@ except KeyboardInterrupt:
|
|||||||
log.debug("Closing websockets")
|
log.debug("Closing websockets")
|
||||||
loop.run_until_complete(stop_management_api())
|
loop.run_until_complete(stop_management_api())
|
||||||
log.debug("Stopping server")
|
log.debug("Stopping server")
|
||||||
loop.run_until_complete(server.stop())
|
try:
|
||||||
|
loop.run_until_complete(asyncio.wait_for(server.stop(), 5, loop=loop))
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
log.warning("Stopping server timed out")
|
||||||
log.debug("Closing event loop")
|
log.debug("Closing event loop")
|
||||||
loop.close()
|
loop.close()
|
||||||
log.debug("Everything stopped, shutting down")
|
log.debug("Everything stopped, shutting down")
|
||||||
|
@ -72,7 +72,7 @@ sockets = []
|
|||||||
async def stop_all() -> None:
|
async def stop_all() -> None:
|
||||||
for socket in sockets:
|
for socket in sockets:
|
||||||
try:
|
try:
|
||||||
await socket.close(1012)
|
await socket.close(code=1012)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -107,7 +107,10 @@ async def log_websocket(request: web.Request) -> web.WebSocketResponse:
|
|||||||
elif not authenticated:
|
elif not authenticated:
|
||||||
await ws.send_json({"auth_success": False})
|
await ws.send_json({"auth_success": False})
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
try:
|
||||||
|
await ws.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
log_root.removeHandler(handler)
|
log_root.removeHandler(handler)
|
||||||
log.debug(f"Connection from {request.remote} closed")
|
log.debug(f"Connection from {request.remote} closed")
|
||||||
sockets.remove(ws)
|
sockets.remove(ws)
|
||||||
|
@ -99,6 +99,7 @@ class MaubotServer:
|
|||||||
self.log.info(f"Listening on {site.name}")
|
self.log.info(f"Listening on {site.name}")
|
||||||
|
|
||||||
async def stop(self) -> None:
|
async def stop(self) -> None:
|
||||||
|
await self.runner.shutdown()
|
||||||
await self.runner.cleanup()
|
await self.runner.cleanup()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user