Compare commits

...

3 Commits

Author SHA1 Message Date
Fabian Dill
0d4ffeca0a WebHost: clean internal checksum as well 2024-04-24 06:23:48 +02:00
Zach Parks
c61649cef3 Add webhost config sample entry 2024-04-23 23:16:54 -05:00
Fabian Dill
7ae102741a WebHost: add startup option to clean datapackages 2024-04-24 05:10:36 +02:00
3 changed files with 21 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ app.config["JOB_THRESHOLD"] = 1
# after what time in seconds should generation be aborted, freeing the queue slot. Can be set to None to disable.
app.config["JOB_TIME"] = 600
app.config['SESSION_PERMANENT'] = True
app.config["CHECK_DATA_PACKAGE_CHECKSUM_ON_STARTUP"] = False
# waitress uses one thread for I/O, these are for processing of views that then get sent
# archipelago.gg uses gunicorn + nginx; ignoring this option

View File

@@ -73,7 +73,22 @@ def autohost(config: dict):
# Command gets deleted by ponyorm Cascade Delete, as Room is Required
if rooms or seeds or slots:
logging.info(f"{rooms} Rooms, {seeds} Seeds and {slots} Slots have been deleted.")
if config["CHECK_DATA_PACKAGE_CHECKSUM_ON_STARTUP"]:
logging.info("Checking for Data Package Checksum integrity")
from worlds.AutoWorld import data_package_checksum
with db_session:
for data_package in GameDataPackage.select():
data = restricted_loads(data_package.data)
if data["checksum"] != data_package.checksum:
logging.warning(f"Deleting mismatching checksum datapackage {data_package.checksum}.")
data_package.delete()
continue
del data["checksum"]
if data_package.checksum != data_package_checksum(data):
logging.warning(f"Deleting mismatching checksum datapackage {data_package.checksum}.")
data_package.delete()
run_guardian()
logging.info("Starting Autohost.")
while 1:
time.sleep(0.1)
with db_session:
@@ -202,6 +217,6 @@ def run_guardian():
guardian = threading.Thread(name="Guardian", target=guard)
from .models import Room, Generation, STATE_QUEUED, STATE_STARTED, STATE_ERROR, db, Seed, Slot
from .models import Room, Generation, STATE_QUEUED, STATE_STARTED, STATE_ERROR, db, Seed, Slot, GameDataPackage
from .customserver import run_server_process, get_static_server_data
from .generate import gen_game

View File

@@ -48,6 +48,10 @@
# TODO
#JSON_AS_ASCII: false
# Performs a check on the database during startup for any data packages with mismatched checksums and clears
# them from the database automatically.
#CHECK_DATA_PACKAGE_CHECKSUM_ON_STARTUP: false
# Host Address. This is the address encoded into the patch that will be used for client auto-connect.
#HOST_ADDRESS: archipelago.gg