From 533b6f41377f994959c328ef4eb43e55e0673bc7 Mon Sep 17 00:00:00 2001 From: cclohmar Date: Tue, 7 Jul 2026 14:53:00 +0100 Subject: [PATCH] fix: full service teardown (stop+disable+remove) + port 80 wait --- deploy.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/deploy.sh b/deploy.sh index 1cd519e..25190a4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -45,21 +45,38 @@ echo "[2/6] Building binary and helper tool..." export PATH=$PATH:/usr/local/go/bin go build -o "$BINARY_NAME" . -TOOL_DIR="$REPO_DIR/tools/nextwks-tool" TOOL_BIN="/tmp/nextwks-tool" -if [ -d "$TOOL_DIR" ]; then - cd "$TOOL_DIR" - go build -o "$TOOL_BIN" . 2>/dev/null && echo "[OK] Helper tool built" || echo "[WARN] Helper tool build failed" +TOOL_SRC="" +for TRY_DIR in "$REPO_DIR/tools/nextwks-tool" "$(dirname $0)/tools/nextwks-tool"; do + if [ -d "$TRY_DIR" ]; then + TOOL_SRC="$TRY_DIR" + break + fi +done +if [ -n "$TOOL_SRC" ]; then + cd "$TOOL_SRC" + go build -o "$TOOL_BIN" . 2>&1 && echo "[OK] Helper tool built" || echo "[WARN] Helper tool build failed" cd "$REPO_DIR" fi # --- Greenfield path --- if [ "$GREENFIELD" = true ]; then - # Step 3: Stop all services and free port 80 for ACME challenge - echo "[3/6] Stopping all services..." + # Step 3: Full teardown — stop, disable, remove all services + echo "[3/6] Full service teardown..." systemctl stop $SERVICE_NAME 2>/dev/null || true + systemctl disable $SERVICE_NAME 2>/dev/null || true + rm -f /etc/systemd/system/$SERVICE_NAME.service + systemctl daemon-reload podman rm -f zoraxy 2>/dev/null || true + # Wait for port 80 to be released + for i in $(seq 1 10); do + if ! ss -tlnp | grep -q ':80 '; then + break + fi + echo " Waiting for port 80 to be released... ($i/10)" + sleep 1 + done # Wipe production directory if [ -d "$TARGET_DIR" ]; then