Files
sentinel-home-ai/scripts/start_core.sh

37 lines
1.2 KiB
Bash
Executable File
Raw 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.
#!/bin/bash
# FAM-Core 启动脚本 (NAS 端)
# 用法: ./scripts/start_core.sh
set -e
# APP_DIR = <repo>/fam-core
APP_DIR="$(cd "$(dirname "$0")/.." && pwd)/fam-core"
CONFIG_FILE="$APP_DIR/config/config.yaml"
if [ ! -f "$CONFIG_FILE" ]; then
echo "错误: 配置文件不存在: $CONFIG_FILE"
echo "请复制 config.yaml.example 为 config.yaml 并修改实际值"
exit 1
fi
cd "$APP_DIR"
# 加载项目级环境变量ORACLE_SYNC_TOKEN / AUTH_HUB_* 等,与甲骨文端保持一致)
# 注意:.env 里 AUTH_HUB_* 是“裸赋值”(无 export 前缀),必须用 set -a 包裹 source
# 否则这些变量只存在于 shell 内、不会 export 给 gunicorn 子进程,导致 fam-core
# 启动后读不到 AUTH_HUB_ISSUER 等、登录被 fail-closed 拒绝(见 auth.py
# 另外 .env 路径基于 $APP_DIR 推导,避免“先 cd 再算 SCRIPT_DIR”的相对路径错位。
ENV_FILE="$APP_DIR/../.env"
if [ -f "$ENV_FILE" ]; then
set -a
source "$ENV_FILE"
set +a
fi
# 检查虚拟环境
if [ -d "venv" ]; then
source venv/bin/activate
fi
echo "启动 FAM-Core (端口 8000)..."
exec gunicorn -w 1 -b 0.0.0.0:8000 --timeout 120 src.fam_core.app:app