Files
momentry_core/scripts/check_config.sh
accusys 732ef9296b feat: add momentry_playground binary for development
- Add separate momentry_playground binary with distinct configuration
- Production (momentry): Port 3002, Redis prefix 'momentry:'
- Development (momentry_playground): Port 3003, Redis prefix 'momentry_dev:'
- Add SERVER_PORT and REDIS_KEY_PREFIX config via environment variables
- Replace all hardcoded Redis key prefixes with configurable values
- Create .env.development for playground environment settings
- Update .env with production defaults
- Add dotenv dependency for environment file loading

Configuration isolation allows running both binaries simultaneously
without port conflicts or Redis key collisions.
2026-03-25 14:53:41 +08:00

97 lines
2.5 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
# Config Check Script
# 驗證配置是否正確設置
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "=========================================="
echo "Momentry Core 配置檢查"
echo "=========================================="
# 檢查 .env 文件
if [ -f ".env" ]; then
echo -e "${GREEN}✅ .env 文件存在${NC}"
else
if [ -f ".env.example" ]; then
echo -e "${YELLOW}⚠️ .env 文件不存在,使用模板創建...${NC}"
cp .env.example .env
echo -e "${YELLOW}⚠️ 已創建 .env請編輯並設置正確的憑據${NC}"
else
echo -e "${RED}❌ .env 和 .env.example 都不存在${NC}"
fi
fi
# 檢查必要配置
check_var() {
local var_name="$1"
local description="$2"
if grep -q "^${var_name}=" .env 2>/dev/null; then
echo -e "${GREEN}${var_name}${NC} - $description"
else
echo -e "${YELLOW}⚠️ ${var_name}${NC} - $description (使用默認值)"
fi
}
if [ -f ".env" ]; then
echo ""
echo "檢查環境變數..."
check_var "DATABASE_URL" "PostgreSQL 連接"
check_var "REDIS_URL" "Redis 連接"
check_var "REDIS_PASSWORD" "Redis 密碼"
check_var "MOMENTRY_OUTPUT_DIR" "輸出目錄"
check_var "MOMENTRY_PYTHON_PATH" "Python 路徑"
check_var "RUST_LOG" "日誌級別"
fi
# 檢查目錄權限
echo ""
echo "檢查目錄權限..."
check_dir() {
local dir="$1"
local description="$2"
if [ -d "$dir" ]; then
if [ -w "$dir" ]; then
echo -e "${GREEN}${dir}${NC} - $description (可寫)"
else
echo -e "${RED}${dir}${NC} - $description (不可寫)"
fi
else
echo -e "${YELLOW}⚠️ ${dir}${NC} - $description (目錄不存在)"
fi
}
check_dir "/Users/accusys/momentry/output" "輸出目錄"
check_dir "/Users/accusys/momentry/backup" "備份目錄"
# 檢查 Python
echo ""
echo "檢查 Python..."
if command -v python3.11 &> /dev/null; then
version=$(python3.11 --version 2>&1)
echo -e "${GREEN}✅ Python 3.11 可用${NC} ($version)"
else
echo -e "${RED}❌ Python 3.11 不可用${NC}"
fi
# 檢查 Rust
echo ""
echo "檢查 Rust..."
if command -v cargo &> /dev/null; then
version=$(cargo --version 2>&1)
echo -e "${GREEN}✅ Cargo 可用${NC} ($version)"
else
echo -e "${RED}❌ Cargo 不可用${NC}"
fi
echo ""
echo "=========================================="
echo "配置檢查完成"
echo "=========================================="