From f73d5d9164b6458137377ba55cfe1351f9764557 Mon Sep 17 00:00:00 2001 From: tommal Date: Wed, 1 Jul 2026 15:17:24 +0200 Subject: [PATCH] Aggiunto un log migliore --- manager-solution/manager/manager.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/manager-solution/manager/manager.py b/manager-solution/manager/manager.py index a919169..0d44b87 100644 --- a/manager-solution/manager/manager.py +++ b/manager-solution/manager/manager.py @@ -58,6 +58,10 @@ def log(message: str) -> None: print(message, flush=True) +def format_access_url(host: str, port: int) -> str: + return f"http://{host}:{port}" + + def get_user_container_lock(user_id: str) -> threading.Lock: with user_container_locks_guard: if user_id not in user_container_locks: @@ -534,7 +538,11 @@ async def main(): servers = [] if GATEWAY_PORT > 0: gateway_server = await asyncio.start_server(handle_gateway_connection, "0.0.0.0", GATEWAY_PORT) - log(f"Shared gateway ready on port {GATEWAY_PORT}") + log( + "Shared gateway ready: " + f"{format_access_url('localhost', GATEWAY_PORT)} " + "(host-based routing: http://.localhost:{GATEWAY_PORT})" + ) servers.append(gateway_server) for user in config["users"]: @@ -542,7 +550,15 @@ async def main(): await handle_connection(reader, writer, configured_user) server = await asyncio.start_server(handler, "0.0.0.0", user["port"]) - log(f"Ready on port {user['port']} for user {user['id']} ({user['container_name']})") + direct_url = format_access_url("localhost", user["port"]) + if GATEWAY_PORT > 0: + gateway_url = format_access_url(f"{user['id']}.localhost", GATEWAY_PORT) + log( + f"Ready for user {user['id']} ({user['container_name']}): " + f"{direct_url} or {gateway_url}" + ) + else: + log(f"Ready for user {user['id']} ({user['container_name']}): {direct_url}") servers.append(server) asyncio.create_task(idle_checker())