Customserver: only save on exit if it's in a good state. (#3351)

This commit is contained in:
Fabian Dill 2024-05-21 14:08:59 +02:00 committed by GitHub
parent fe7bc8784d
commit 461f5db35a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -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)