Merge branch 'dev' into test-save
This commit is contained in:
commit
65339b5435
@ -20,8 +20,11 @@ COPY --from=pybuilder /code /dist
|
|||||||
# copy the frontend static files from the builder
|
# copy the frontend static files from the builder
|
||||||
COPY --from=builder ./dist /dist/
|
COPY --from=builder ./dist /dist/
|
||||||
WORKDIR /dist
|
WORKDIR /dist
|
||||||
|
# create dir for save
|
||||||
|
RUN mkdir save
|
||||||
EXPOSE 5001
|
EXPOSE 5001
|
||||||
|
|
||||||
ENV PATH=/root/.local/bin:${PATH}
|
ENV PATH=/root/.local/bin:${PATH}
|
||||||
|
VOLUME /dist/save
|
||||||
|
|
||||||
ENTRYPOINT ["python", "/dist/server.py"]
|
ENTRYPOINT ["python", "/dist/server.py"]
|
||||||
|
@ -813,13 +813,13 @@ def save_games():
|
|||||||
while True:
|
while True:
|
||||||
sio.sleep(2)
|
sio.sleep(2)
|
||||||
if not save_lock:
|
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)
|
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 __name__ == '__main__':
|
||||||
if os.path.exists('games.pickle'):
|
if os.path.exists('./save/games.pickle'):
|
||||||
try:
|
try:
|
||||||
with open('games.pickle', 'rb') as file:
|
with open('./save/games.pickle', 'rb') as file:
|
||||||
games = pickle.load(file)
|
games = pickle.load(file)
|
||||||
for g in games:
|
for g in games:
|
||||||
for p in g.players:
|
for p in g.players:
|
||||||
|
Loading…
Reference in New Issue
Block a user