#!/usr/bin/env bash # ============================================================ # go-sms 一键停止前后端(scripts/dev_down.sh / make dev-stop) # 停止:Web(:WEB_PORT) → 网关 → submit 消费者(若在运行) # 说明:中间件容器不动(完全清理含数据卷:make down,慎用) # 变量:WEB_PORT=5173 可覆盖 # ============================================================ set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" WEB_PORT="${WEB_PORT:-5173}" make web-stop WEB_PORT="$WEB_PORT" make gw-stop if [ -f logs/consumer.pid ] && kill -0 "$(cat logs/consumer.pid)" 2>/dev/null; then kill "$(cat logs/consumer.pid)" && echo ">> submit 消费者已停止" fi rm -f logs/consumer.pid if curl -sf -m 2 -o /dev/null "http://127.0.0.1:${GW_PORT:-8080}/health" 2>/dev/null; then echo ">> 提示:网关 :${GW_PORT:-8080} 仍在响应(pid 文件缺失,非 make gw-start 启动?)" echo ">> 如需强制停止: pkill -f bin/gateway" fi echo ">> 中间件容器仍在运行(make down 可完全清理,含数据卷)"