Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.5 KiB
Bash
Executable File
41 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Ensure web/API services inside DBIS containers (10130, 10150, 10151) are running.
|
|
# Fixes 502 when containers are up but nginx or app inside is stopped.
|
|
#
|
|
# Usage: ./scripts/maintenance/ensure-dbis-services-via-ssh.sh [--dry-run]
|
|
# Env: PROXMOX_HOST_R630_01 (default 192.168.11.11)
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
[[ -f "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" ]] && source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" 2>/dev/null || true
|
|
|
|
DRY_RUN=false
|
|
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
|
|
|
|
PROXMOX_HOST="${PROXMOX_HOST_R630_01:-192.168.11.11}"
|
|
|
|
log_info() { echo -e "\033[0;34m[INFO]\033[0m $1"; }
|
|
log_ok() { echo -e "\033[0;32m[✓]\033[0m $1"; }
|
|
log_warn() { echo -e "\033[0;33m[⚠]\033[0m $1"; }
|
|
|
|
run_ssh() { ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@"$PROXMOX_HOST" "$@"; }
|
|
|
|
echo ""
|
|
echo "=== Ensure DBIS container services (fix 502) ==="
|
|
echo " Host: $PROXMOX_HOST dry-run=$DRY_RUN"
|
|
echo ""
|
|
|
|
for vmid in 10130 10150 10151; do
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
log_info "Would ensure nginx/node in VMID $vmid"
|
|
continue
|
|
fi
|
|
status=$(run_ssh "pct status $vmid 2>/dev/null | awk '{print \$2}'" 2>/dev/null || echo "missing")
|
|
[[ "$status" != "running" ]] && { log_warn "VMID $vmid not running"; continue; }
|
|
run_ssh "pct exec $vmid -- systemctl start nginx 2>/dev/null" || true
|
|
run_ssh "pct exec $vmid -- systemctl start node 2>/dev/null" || true
|
|
log_ok "VMID $vmid services started"
|
|
done
|
|
echo ""
|