volume save

This commit is contained in:
GM 2023-01-22 20:51:44 +00:00
parent 8b0b5228de
commit 292fbe4dde
2 changed files with 4 additions and 3 deletions

View File

@ -23,5 +23,6 @@ WORKDIR /dist
EXPOSE 5001
ENV PATH=/root/.local/bin:${PATH}
VOLUME /code/save
ENTRYPOINT ["python", "/dist/server.py"]

View File

@ -813,13 +813,13 @@ def save_games():
while True:
sio.sleep(2)
if not save_lock:
with open('games.pickle', 'wb') as f:
with open('./save/games.pickle', 'wb') as f:
pickle.dump([g for g in games if g.started and not g.is_replay and not g.is_hidden], f)
if __name__ == '__main__':
if os.path.exists('games.pickle'):
if os.path.exists('./save/games.pickle'):
try:
with open('games.pickle', 'rb') as file:
with open('./save/games.pickle', 'rb') as file:
games = pickle.load(file)
for g in games:
for p in g.players: