Merge branch 'dev' into test-save

This commit is contained in:
Giulio 2023-01-23 09:00:09 +01:00
commit 65339b5435
2 changed files with 6 additions and 3 deletions

View File

@ -20,8 +20,11 @@ COPY --from=pybuilder /code /dist
# copy the frontend static files from the builder
COPY --from=builder ./dist /dist/
WORKDIR /dist
# create dir for save
RUN mkdir save
EXPOSE 5001
ENV PATH=/root/.local/bin:${PATH}
VOLUME /dist/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: