elder-yudao-pro/deploy/local/start-mobile.sh

21 lines
959 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
ensure_runtime_dir
MOBILE_DIR="$REPO_DIR/elderly-health-app"
MOBILE_BIN="$MOBILE_DIR/node_modules/@dcloudio/vite-plugin-uni/bin/uni.js"
[[ -f "$MOBILE_BIN" ]] || { echo '请先在 elderly-health-app 安装冻结锁文件依赖。' >&2; exit 1; }
PID_FILE="$RUNTIME_DIR/mobile.pid"
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo '移动端已在运行。'; exit 1
fi
MOBILE_PORT="${ELDER_MOBILE_PORT:-48082}"
if command -v lsof >/dev/null && lsof -nP -iTCP:"$MOBILE_PORT" -sTCP:LISTEN >/dev/null; then
echo "端口 $MOBILE_PORT 已被占用。" >&2; exit 1
fi
NODE="$(resolve_node)"
cd "$MOBILE_DIR"
nohup "$NODE" "$MOBILE_BIN" --host 127.0.0.1 --port "$MOBILE_PORT" > "$RUNTIME_DIR/mobile-stdout.log" 2> "$RUNTIME_DIR/mobile-stderr.log" &
echo $! > "$PID_FILE"
echo "移动端已启动:http://127.0.0.1:$MOBILE_PORT/"