65 lines
2.2 KiB
Bash
Executable File
65 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# MCPletA2A — status.sh
|
|
# Shows running state of all managed services.
|
|
# =============================================================================
|
|
set -uo pipefail
|
|
|
|
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PID_DIR="$BASE_DIR/.pids"
|
|
LOG_DIR="$BASE_DIR/.logs"
|
|
|
|
GREEN='\033[0;32m'; RED='\033[0;31m'; YELLOW='\033[1;33m'
|
|
CYAN='\033[0;36m'; BOLD='\033[1m'; RESET='\033[0m'
|
|
|
|
check_service() {
|
|
local name="$1"
|
|
local label="$2"
|
|
local url="${3:-}"
|
|
local pidfile="$PID_DIR/$name.pid"
|
|
|
|
if [[ ! -f "$pidfile" ]]; then
|
|
echo -e " ${RED}●${RESET} ${BOLD}$label${RESET} ${RED}(not started)${RESET}"
|
|
return
|
|
fi
|
|
|
|
local pid
|
|
pid=$(cat "$pidfile")
|
|
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
local url_hint=""
|
|
[[ -n "$url" ]] && url_hint=" → ${CYAN}$url${RESET}"
|
|
echo -e " ${GREEN}●${RESET} ${BOLD}$label${RESET} pid=${pid}${url_hint}"
|
|
else
|
|
echo -e " ${YELLOW}●${RESET} ${BOLD}$label${RESET} ${YELLOW}(stale pid $pid — process not found)${RESET}"
|
|
fi
|
|
}
|
|
|
|
tail_log() {
|
|
local name="$1"
|
|
local logfile="$LOG_DIR/$name.log"
|
|
if [[ -f "$logfile" ]]; then
|
|
echo -e "\n ${BOLD}Last 5 lines of $name.log:${RESET}"
|
|
tail -n 5 "$logfile" | sed 's/^/ /'
|
|
fi
|
|
}
|
|
|
|
echo ""
|
|
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
|
|
echo -e "${BOLD} MCPletA2A Service Status${RESET}"
|
|
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
|
|
check_service "mock-services" "Mock Service " "http://localhost:5100"
|
|
check_service "platform-host" "Platform Host " "http://localhost:4000 (Dashboard)"
|
|
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
|
|
|
|
if [[ "${1:-}" == "-l" || "${1:-}" == "--logs" ]]; then
|
|
tail_log "mock-services"
|
|
tail_log "platform-host"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e " ${CYAN}./start.sh${RESET} start all services"
|
|
echo -e " ${CYAN}./stop.sh${RESET} stop all services"
|
|
echo -e " ${CYAN}./status.sh -l${RESET} show recent logs"
|
|
echo ""
|