fix: full service teardown (stop+disable+remove) + port 80 wait
This commit is contained in:
parent
434b23aee2
commit
533b6f4137
1 changed files with 23 additions and 6 deletions
29
deploy.sh
29
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue