40 lines
927 B
Bash
Executable File
40 lines
927 B
Bash
Executable File
#!/usr/bin/env bash
|
||
# 停止 gateway + web(不碰 infra / 資料)
|
||
set -euo pipefail
|
||
# shellcheck source=_common.sh
|
||
source "$(cd "$(dirname "$0")" && pwd)/_common.sh"
|
||
|
||
log "stopping apps…"
|
||
|
||
if [[ -f "$PID_GATEWAY" ]]; then
|
||
gpid="$(cat "$PID_GATEWAY" 2>/dev/null || true)"
|
||
if pid_alive "$gpid"; then
|
||
log "gateway pid=$gpid"
|
||
kill "$gpid" 2>/dev/null || true
|
||
sleep 0.5
|
||
kill -9 "$gpid" 2>/dev/null || true
|
||
fi
|
||
rm -f "$PID_GATEWAY"
|
||
fi
|
||
|
||
if [[ -f "$PID_WEB" ]]; then
|
||
wpid="$(cat "$PID_WEB" 2>/dev/null || true)"
|
||
if pid_alive "$wpid"; then
|
||
log "web pid=$wpid"
|
||
# vite 常是 npm 父行程;也清 port
|
||
kill "$wpid" 2>/dev/null || true
|
||
sleep 0.5
|
||
kill -9 "$wpid" 2>/dev/null || true
|
||
fi
|
||
rm -f "$PID_WEB"
|
||
fi
|
||
|
||
# 保險:依埠清
|
||
load_env 2>/dev/null || true
|
||
kill_port "${GATEWAY_PORT:-8888}"
|
||
kill_port "${WEB_PORT:-5173}"
|
||
# vite 有時落到 5174
|
||
kill_port 5174
|
||
|
||
log "apps stopped"
|