import os import subprocess import globals import sys def main(): if globals.is_debugging(): import debugpy debugpy.listen(("0.0.0.0", 5678)) print("INFO: Waiting for debugger to attach...") debugpy.wait_for_client() print("INFO: Debugger attached") else: print("👉 starting setup") setup_container() if globals.is_debugging(): debug_file = os.getenv("DEBUG_FILE", "") if debug_file and os.path.isfile(debug_file): print(f"🔍 Running debug file: {debug_file}") subprocess.run(["python3", debug_file], check=True, stdout=sys.stdout, stderr=sys.stderr) return False elif debug_file: print(f"⚠️ DEBUG_FILE set but file not found: {debug_file}") return True def setup_container(): marker_file = "/var/run/container_initialized" if not os.path.exists(marker_file): print("INFO: First-time setup running...") # 👉 Your one-time setup logic here # Create the marker file with open(marker_file, "w") as f: f.write("initialized\n") else: print("TRACE: Already initialized. Skipping setup.")