#!/bin/bash # 查看所有服务状态 DEPLOY_HOME="/opt/fundplatform/deploy" SERVICES=( "fund-gateway:8000" "fund-sys:8100" "fund-cust:8200" "fund-proj:8300" "fund-req:8400" "fund-exp:8500" "fund-receipt:8600" "fund-report:8700" "fund-file:8800" ) echo "==========================================" echo " Service Status" echo "==========================================" printf "%-20s %-10s %-10s %s\n" "Service" "Port" "Status" "PID" echo "------------------------------------------" for item in "${SERVICES[@]}"; do service="${item%%:*}" port="${item##*:}" pid_file="${DEPLOY_HOME}/${service}/${service}.pid" if [ -f "$pid_file" ]; then PID=$(cat $pid_file) if ps -p $PID > /dev/null 2>&1; then printf "%-20s %-10s \033[32m%-10s\033[0m %s\n" "$service" "$port" "RUNNING" "$PID" else printf "%-20s %-10s \033[31m%-10s\033[0m %s\n" "$service" "$port" "STOPPED" "-" fi else printf "%-20s %-10s \033[31m%-10s\033[0m %s\n" "$service" "$port" "STOPPED" "-" fi done echo "=========================================="