diff --git a/MultiServer.py b/MultiServer.py index 45363b24..397daedf 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -1034,7 +1034,7 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict): if ctx.compatibility == 0 and args['version'] != version_tuple: errors.add('IncompatibleVersion') if errors: - logging.info(f"A client connection was refused due to: {errors}") + logging.info(f"A client connection was refused due to: {errors}, the sent connect information was {args}.") await ctx.send_msgs(client, [{"cmd": "ConnectionRefused", "errors": list(errors)}]) else: ctx.client_ids[client.team, client.slot] = args["uuid"] diff --git a/WebHostLib/autolauncher.py b/WebHostLib/autolauncher.py index 839529b9..e3d77500 100644 --- a/WebHostLib/autolauncher.py +++ b/WebHostLib/autolauncher.py @@ -15,10 +15,13 @@ from Utils import restricted_loads class CommonLocker(): """Uses a file lock to signal that something is already running""" - - def __init__(self, lockname: str): + lock_folder = "file_locks" + def __init__(self, lockname: str, folder=None): + if folder: + self.lock_folder = folder + os.makedirs(self.lock_folder, exist_ok=True) self.lockname = lockname - self.lockfile = f"./{self.lockname}.lck" + self.lockfile = os.path.join(self.lock_folder, f"{self.lockname}.lck") class AlreadyRunningException(Exception): diff --git a/WebHostLib/customserver.py b/WebHostLib/customserver.py index 317fd150..404a096f 100644 --- a/WebHostLib/customserver.py +++ b/WebHostLib/customserver.py @@ -104,6 +104,7 @@ class WebHostContext(Context): def get_random_port(): return random.randint(49152, 65535) + def run_server_process(room_id, ponyconfig: dict): # establish DB connection for multidata and multisave db.bind(**ponyconfig) @@ -144,7 +145,9 @@ def run_server_process(room_id, ponyconfig: dict): await ctx.shutdown_task logging.info("Shutting down") - asyncio.run(main()) + from .autolauncher import Locker + with Locker(room_id): + asyncio.run(main()) from WebHostLib import LOGS_FOLDER