diff --git a/07-start-frontend.sh b/07-start-frontend.sh index 08f4d4f..ee61430 100755 --- a/07-start-frontend.sh +++ b/07-start-frontend.sh @@ -20,6 +20,16 @@ set -euo pipefail source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh" init_dirs + +# 供文末打印访问地址(set -u 下须已定义;与 01-init-env 中 DEPLOY_TEST_IP 一致) +if [[ -f "$ENV_FILE" ]]; then + set -a + # shellcheck source=/dev/null + source "$ENV_FILE" + set +a +fi +DEPLOY_TEST_IP="${DEPLOY_TEST_IP:-127.0.0.1}" + init_script_log # ← 脚本执行日志 header "启动前端开发服务器" diff --git a/common.sh b/common.sh index 343c03d..2b5f36f 100755 --- a/common.sh +++ b/common.sh @@ -185,7 +185,8 @@ start_svc() { # ── 停止单个后端服务 ──────────────────────────────────────────────────────────── stop_svc() { - local name="$1" pidfile="$PID_DIR/$name.pid" + local name="$1" + local pidfile="$PID_DIR/$name.pid" if [[ -f "$pidfile" ]]; then local pid; pid=$(cat "$pidfile") if kill -0 "$pid" 2>/dev/null; then @@ -213,7 +214,8 @@ print_container_status() { # ── 后端服务状态打印 ──────────────────────────────────────────────────────────── print_svc_status() { - local name="$1" desc="$2" pidfile="$PID_DIR/$name.pid" + local name="$1" desc="$2" + local pidfile="$PID_DIR/$name.pid" if [[ -f "$pidfile" ]] && kill -0 "$(cat "$pidfile")" 2>/dev/null; then printf " ${GREEN}●${NC} %-18s PID=%-7s %s\n" "$name" "$(cat "$pidfile")" "$desc" else