First running version

This commit is contained in:
qingjie.du
2026-03-30 17:39:13 +09:00
parent 5ffea3d849
commit bce2a5672c
67 changed files with 16503 additions and 0 deletions

64
status.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/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 ""