From 202f0e2dc8be6f1730c933b6f47ec447cb856b32 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 3 Aug 2026 17:28:57 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20start.sh=20per=20node=20=E2=80=94=20decl?= =?UTF-8?q?arative=20config=20+=20startup,=20no=20compose=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/python/main.py | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/sources/python/main.py b/sources/python/main.py index 55fa215..7a396f0 100644 --- a/sources/python/main.py +++ b/sources/python/main.py @@ -57,27 +57,25 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label host_dir = f"{BASE}/{name}" os.makedirs(host_dir, exist_ok=True) - # Generate compose.yaml - compose_path = f"{host_dir}/compose.yaml" - with open(compose_path, "w") as f: - f.write(f"""services: - wallarm: - image: {WALLARM_IMAGE} - container_name: {container} - restart: always - ports: - - "{port}:80" - environment: - - WALLARM_API_TOKEN={token} - - WALLARM_API_HOST={api_host} - - WALLARM_MODE={mode} - volumes: - - ./nginx.conf:/etc/nginx/http.d/default.conf:ro - logging: - driver: json-file - options: - max-size: 10m + # Generate start.sh (declarative config + startup in one file) + start_path = f"{host_dir}/start.sh" + with open(start_path, "w") as f: + f.write(f"""#!/bin/bash +# Wallarm node: {name} +docker rm -f {container} 2>/dev/null || true +docker run -d \\ + --name {container} \\ + --restart always \\ + -p {port}:80 \\ + -e WALLARM_API_TOKEN='{token}' \\ + -e WALLARM_API_HOST={api_host} \\ + -e WALLARM_MODE={mode} \\ + -v {host_dir}/nginx.conf:/etc/nginx/http.d/default.conf:ro \\ + {WALLARM_IMAGE} +sleep 3 +docker ps --filter name={container} --format '{{{{.Status}}}}' """) + os.chmod(start_path, 0o755) # Write nginx.conf with production defaults nginx_conf = f"{host_dir}/nginx.conf" @@ -106,8 +104,8 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label }} """) - print(f"[{name}] Starting via compose...") - r = run(f"cd {host_dir} && docker compose up -d", timeout=30) + print(f"[{name}] Starting...") + r = run(f"bash {start_path}", timeout=30) if r.returncode != 0: print(f"❌ {name}: {r.stderr}") return False