c6cbb5d1fb
- ASR-ASRX unified processor (asr_asrx → asrx), output .asrx.json - ffmpeg -vsync → -fps_mode (swift_ocr, swift_hand, swift_pose, frame_cache) - ffprobe absolute path for probe - PYTHONPATH + PATH added to executor subprocesses - cut processor path fix (cut/cut_processor.py) - scene_vlm fallback when blur_scores empty + ffmpeg absolute path - rust_store_traced_faces generates key_face.jpg with --video-path - face group representative trace picks highest best_confidence - Studio: move FS doesn't remove from unassigned, always reload after move - Studio: confirmMoveFaceToNewGroup simplified to just rename - Studio: scene_vlm added to processors list - Studio: scene_vlm shows (0) when ready but no scenes - admin_config asr_config block added
144 lines
5.3 KiB
Bash
Executable File
144 lines
5.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Momentry Core 安裝腳本
|
|
set -e
|
|
|
|
APP_NAME="MomentryCore"
|
|
INSTALL_DIR="$HOME/Library/Application Support/$APP_NAME"
|
|
LAUNCHD_DIR="$HOME/Library/LaunchAgents"
|
|
LOG_DIR="$INSTALL_DIR/logs"
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
|
|
echo "================================================"
|
|
echo " Momentry Core 安裝程式"
|
|
echo "================================================"
|
|
|
|
# 1. 檢查依賴
|
|
echo ">>> 檢查系統依賴..."
|
|
MISSING=""
|
|
check() {
|
|
if eval "$2" >/dev/null 2>&1; then
|
|
echo " [OK] $1"
|
|
else
|
|
echo " [FAIL] $1 - $3"
|
|
MISSING="$MISSING $1"
|
|
fi
|
|
}
|
|
check "PostgreSQL" "psql --version" "brew install postgresql"
|
|
check "Redis" "redis-cli ping" "brew install redis"
|
|
check "Qdrant" "curl -s --max-time 3 http://localhost:6333/ready | grep -q ok" "brew install qdrant"
|
|
check "MongoDB" "mongosh --version || mongo --version" "brew install mongosh"
|
|
check "Python 3.11" "python3.11 --version" "brew install python@3.11"
|
|
check "ffprobe" "ffprobe -version" "brew install ffmpeg"
|
|
check "MarkBaseServer" "curl -s --max-time 3 http://localhost:8080/v1/models | grep -q model" "安裝 MarkBaseEngine"
|
|
|
|
if [ -n "$MISSING" ]; then
|
|
echo -e "\n${RED}缺少依賴:$MISSING${NC}"
|
|
echo "brew install postgresql redis mongosh ffmpeg python@3.11"
|
|
exit 1
|
|
fi
|
|
echo -e "\n${GREEN}所有依賴已安裝${NC}"
|
|
|
|
# 2. 建立目錄
|
|
echo ">>> 建立目錄..."
|
|
mkdir -p "$INSTALL_DIR"/{bin,config,tools/script,tools/cli,logs}
|
|
SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cp -f "$SRC_DIR/bin/momentry" "$INSTALL_DIR/bin/" 2>/dev/null || echo " [!] momentry binary 需手動放置"
|
|
cp -f "$SRC_DIR/bin/pipeline_worker" "$INSTALL_DIR/bin/" 2>/dev/null || echo " [!] pipeline_worker 需手動放置"
|
|
chmod +x "$INSTALL_DIR/bin/"* 2>/dev/null || true
|
|
cp -rf "$SRC_DIR/config/"* "$INSTALL_DIR/config/" 2>/dev/null || true
|
|
cp -rf "$SRC_DIR/tools/"* "$INSTALL_DIR/tools/" 2>/dev/null || true
|
|
echo " -> $INSTALL_DIR"
|
|
|
|
# 3. 產生 .env
|
|
ENV_FILE="$INSTALL_DIR/.env"
|
|
if [ ! -f "$ENV_FILE" ]; then
|
|
cat > "$ENV_FILE" << ENVEOF
|
|
DATABASE_URL=postgres://accusys@localhost:5432/momentry
|
|
DATABASE_SCHEMA=public
|
|
REDIS_URL=redis://:accusys@localhost:6379
|
|
MOMENTRY_REDIS_PREFIX=momentry:
|
|
MOMENTRY_SERVER_PORT=3002
|
|
MOMENTRY_OUTPUT_DIR=$HOME/momentry/output
|
|
QDRANT_URL=http://127.0.0.1:6333
|
|
MONGODB_URL=mongodb://localhost:27017
|
|
MOMENTRY_LLM_VISION_URL=http://127.0.0.1:8080/v1/chat/completions
|
|
MOMENTRY_LLM_VISION_MODEL=gemma-4-12b-it
|
|
MOMENTRY_LLM_CHAT_URL=http://127.0.0.1:8080/v1/chat/completions
|
|
MOMENTRY_LLM_CHAT_MODEL=gemma-4-12b-it
|
|
MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
|
|
MOMENTRY_SCRIPTS_DIR=$INSTALL_DIR/tools/script
|
|
MOMENTRY_CLI_DIR=$INSTALL_DIR/tools/cli
|
|
RUST_LOG=info
|
|
ENVEOF
|
|
echo " [OK] 已產生 .env"
|
|
else
|
|
echo " [OK] .env 已存在"
|
|
fi
|
|
|
|
# 4. 安裝 Launchd
|
|
echo ">>> 安裝 launchd services..."
|
|
cat > "$LAUNCHD_DIR/com.momentry-core.server.plist" << PLIST
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0"><dict>
|
|
<key>Label</key><string>com.momentry-core.server</string>
|
|
<key>Program</key><string>$INSTALL_DIR/bin/momentry</string>
|
|
<key>ProgramArguments</key><array>
|
|
<string>momentry</string><string>server</string>
|
|
<string>--host</string><string>0.0.0.0</string>
|
|
<string>--port</string><string>3002</string>
|
|
</array>
|
|
<key>WorkingDirectory</key><string>$INSTALL_DIR</string>
|
|
<key>EnvironmentVariables</key><dict>
|
|
<key>DOTENV_PATH</key><string>$ENV_FILE</string>
|
|
</dict>
|
|
<key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>
|
|
<key>RunAtLoad</key><true/>
|
|
<key>StandardOutPath</key><string>$LOG_DIR/server.log</string>
|
|
<key>StandardErrorPath</key><string>$LOG_DIR/server.log</string>
|
|
</dict></plist>
|
|
PLIST
|
|
|
|
cat > "$LAUNCHD_DIR/com.momentry-core.worker.plist" << PLIST
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0"><dict>
|
|
<key>Label</key><string>com.momentry-core.worker</string>
|
|
<key>Program</key><string>$INSTALL_DIR/bin/pipeline_worker</string>
|
|
<key>WorkingDirectory</key><string>$INSTALL_DIR</string>
|
|
<key>EnvironmentVariables</key><dict>
|
|
<key>DOTENV_PATH</key><string>$ENV_FILE</string>
|
|
</dict>
|
|
<key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>
|
|
<key>RunAtLoad</key><true/>
|
|
<key>StandardOutPath</key><string>$LOG_DIR/worker.log</string>
|
|
<key>StandardErrorPath</key><string>$LOG_DIR/worker.log</string>
|
|
</dict></plist>
|
|
PLIST
|
|
echo " [OK] server + worker plist"
|
|
|
|
# 5. 啟動
|
|
echo ">>> 啟動服務..."
|
|
launchctl bootout "gui/$(id -u)/com.momentry-core.server" 2>/dev/null || true
|
|
launchctl bootout "gui/$(id -u)/com.momentry-core.worker" 2>/dev/null || true
|
|
sleep 1
|
|
launchctl bootstrap "gui/$(id -u)" "$LAUNCHD_DIR/com.momentry-core.server.plist"
|
|
launchctl bootstrap "gui/$(id -u)" "$LAUNCHD_DIR/com.momentry-core.worker.plist"
|
|
sleep 3
|
|
|
|
if curl -s --max-time 5 "http://localhost:3002/api/v1/health" >/dev/null 2>&1; then
|
|
echo -e "${GREEN}[OK] API server 啟動成功${NC}"
|
|
else
|
|
echo -e "${YELLOW}[!] 檢查日誌: $LOG_DIR/server.log${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo "================================================"
|
|
echo " 安裝完成!"
|
|
echo " 目錄: $INSTALL_DIR"
|
|
echo " API: http://localhost:3002"
|
|
echo "================================================"
|