From 461f5db35a0758204e6db0e0ddf64efedef98339 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 21 May 2024 14:08:59 +0200 Subject: [PATCH] Customserver: only save on exit if it's in a good state. (#3351) --- WebHostLib/customserver.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/WebHostLib/customserver.py b/WebHostLib/customserver.py index bc9f74ba..16769b7a 100644 --- a/WebHostLib/customserver.py +++ b/WebHostLib/customserver.py @@ -270,15 +270,19 @@ def run_server_process(name: str, ponyconfig: dict, static_server_data: dict, await ctx.shutdown_task except (KeyboardInterrupt, SystemExit): - pass - except Exception: + if ctx.saving: + ctx._save() + except Exception as e: with db_session: room = Room.get(id=room_id) room.last_port = -1 + logger.exception(e) raise + else: + if ctx.saving: + ctx._save() finally: try: - ctx._save() with (db_session): # ensure the Room does not spin up again on its own, minute of safety buffer room = Room.get(id=room_id)