fix: proper teardown and health check for podman network
This commit is contained in:
parent
2ce600bb6d
commit
079ca4bedb
1 changed files with 17 additions and 3 deletions
20
deploy.sh
20
deploy.sh
|
|
@ -35,7 +35,17 @@ go build -o nextworkspace .
|
||||||
# --- Greenfield ---
|
# --- Greenfield ---
|
||||||
if [ "$GREENFIELD" = true ]; then
|
if [ "$GREENFIELD" = true ]; then
|
||||||
echo "[3/6] Full teardown..."
|
echo "[3/6] Full teardown..."
|
||||||
|
# Stop systemd service if still running
|
||||||
|
systemctl stop nextworkspace 2>/dev/null || true
|
||||||
|
systemctl disable nextworkspace 2>/dev/null || true
|
||||||
|
rm -f /etc/systemd/system/nextworkspace.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
# Remove containers (both root and master user)
|
||||||
podman rm -f caddy authelia launcher 2>/dev/null || true
|
podman rm -f caddy authelia launcher 2>/dev/null || true
|
||||||
|
sudo -u master podman rm -f caddy authelia launcher 2>/dev/null || true
|
||||||
|
# Remove old network
|
||||||
|
podman network rm nextwks-net 2>/dev/null || true
|
||||||
|
sudo -u master podman network rm nextwks-net 2>/dev/null || true
|
||||||
|
|
||||||
if [ -d "$TARGET_DIR" ]; then
|
if [ -d "$TARGET_DIR" ]; then
|
||||||
chattr -R -i "$TARGET_DIR" 2>/dev/null || true
|
chattr -R -i "$TARGET_DIR" 2>/dev/null || true
|
||||||
|
|
@ -105,6 +115,8 @@ if [ "$GREENFIELD" = true ]; then
|
||||||
# Create podman network
|
# Create podman network
|
||||||
echo "[5/6] Creating podman network..."
|
echo "[5/6] Creating podman network..."
|
||||||
podman network create --subnet 172.16.0.0/24 "$NETWORK_NAME" 2>/dev/null || true
|
podman network create --subnet 172.16.0.0/24 "$NETWORK_NAME" 2>/dev/null || true
|
||||||
|
# Ensure network exists for rootless too
|
||||||
|
sudo -u master podman network create --subnet 172.16.0.0/24 "$NETWORK_NAME" 2>/dev/null || true
|
||||||
|
|
||||||
# Deploy all containers
|
# Deploy all containers
|
||||||
echo "[6/6] Deploying containers..."
|
echo "[6/6] Deploying containers..."
|
||||||
|
|
@ -132,13 +144,15 @@ fi
|
||||||
# --- Health check ---
|
# --- Health check ---
|
||||||
echo "[*] Running health check..."
|
echo "[*] Running health check..."
|
||||||
for i in $(seq 1 $HEALTH_CHECK_RETRIES); do
|
for i in $(seq 1 $HEALTH_CHECK_RETRIES); do
|
||||||
if curl -sf http://127.0.0.1:9000/health > /dev/null 2>&1; then
|
HEALTH=$(podman exec launcher wget -qO- http://127.0.0.1:9000/health 2>/dev/null || \
|
||||||
echo "[OK] NextWorkspace launcher is healthy on http://127.0.0.1:9000/"
|
sudo -u master podman exec launcher wget -qO- http://127.0.0.1:9000/health 2>/dev/null || echo "")
|
||||||
|
if [ "$HEALTH" = "OK" ]; then
|
||||||
|
echo "[OK] NextWorkspace launcher is healthy"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo " Attempt $i/$HEALTH_CHECK_RETRIES — not ready yet..."
|
echo " Attempt $i/$HEALTH_CHECK_RETRIES — not ready yet..."
|
||||||
sleep $HEALTH_CHECK_INTERVAL
|
sleep $HEALTH_CHECK_INTERVAL
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "[FAIL] Health check failed — launcher did not respond on port 9000"
|
echo "[FAIL] Health check failed — launcher did not respond"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue