Files
asf/scripts/status-stack.sh
2026-09-08 07:21:34 -04:00

42 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# status-stack.sh — PIDs, logs, HTTP live per ASF Core/Web/Worker.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PID_FILE="$ROOT_DIR/var/run/asf-stack.pids"
LOG_DIR="$ROOT_DIR/var/log/asf"
echo "ASF stack STATUS $(date '+%F %T %Z')"
echo
printf "%-18s %-8s %-6s %-6s %s\n" "NAME" "PID" "PORT" "HTTP" "LOG"
printf '─%.0s' $(seq 1 90); echo
check_http() {
local url="$1"
curl -s -m 3 -o /dev/null -w '%{http_code}' "$url" 2>/dev/null || echo "000"
}
# Core
pid=$(pgrep -f "uvicorn app.main:app" 2>/dev/null | head -1 || true)
http=$(check_http "http://127.0.0.1:8000/api/v1/health")
printf "%-18s %-8s %-6s %-6s %s\n" "asf-core" "${pid:--}" "8000" "$http" "$LOG_DIR/asf-core.log"
# Web
pid=$(pgrep -af "next-server|next dev" 2>/dev/null | awk '{print $1}' | head -1 || true)
http=$(check_http "http://127.0.0.1:3000/")
printf "%-18s %-8s %-6s %-6s %s\n" "asf-web" "${pid:--}" "3000" "$http" "$LOG_DIR/asf-web.log"
# Worker
pid=$(pgrep -f "python -m app.worker" 2>/dev/null | head -1 || true)
printf "%-18s %-8s %-6s %-6s %s\n" "asf-worker" "${pid:--}" "AMQP" "-" "$LOG_DIR/asf-worker.log"
echo
echo "Pid file:"; [ -f "$PID_FILE" ] && cat "$PID_FILE" || echo " (nessuno)"
echo
echo "Logs tail (10 lines most recent each):"
for f in "$LOG_DIR"/*.log; do
[ -e "$f" ] || continue
echo
echo "───── $f (last 10 lines) ─────"
tail -10 "$f" | sed 's/^/ │ /'
done