File size: 1,611 Bytes
c1a43bf
 
 
 
 
 
 
 
 
96e1383
 
 
 
 
 
 
 
 
 
 
 
 
 
c1a43bf
 
 
 
 
 
 
 
 
 
 
 
 
96e1383
 
 
 
 
 
 
 
 
 
c1a43bf
 
96e1383
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# ============================================
# Entrypoint Script for Hugging Face Spaces
# ============================================

echo "============================================"
echo "CLIProxyAPI Plus - Hugging Face Spaces"
echo "============================================"

# 檢查 Go 二進制是否存在
GO_BINARY="/app/go-server/CLIProxyAPIPlus"
if [ -f "$GO_BINARY" ]; then
    echo "✓ Go API Server found: $GO_BINARY"
    chmod +x "$GO_BINARY"
    # 啟動 Go 服務器
    echo "Starting Go API Server..."
    /app/go-server/CLIProxyAPIPlus &
    export GO_SERVER_PID=$!
    export HAS_GO_SERVER=true
else
    echo "⚠ Go API Server not found - Running in Streamlit-only mode"
    echo "  To enable full mode, build and include CLIProxyAPIPlus binary"
    export HAS_GO_SERVER=false
fi

# 創建必要的目錄
mkdir -p /root/.cli-proxy-api
mkdir -p /app/logs
mkdir -p /app/auths

# 設置權限
chmod -R 755 /app

# 顯示環境資訊
echo ""
echo "Environment Information:"
if [ "$HAS_GO_SERVER" = "true" ]; then
    echo " - Mode: Full (Go API + Streamlit)"
    echo " - API Server Port: 8317 (internal)"
    echo " - Go Server PID: $GO_SERVER_PID"
else
    echo " - Mode: Streamlit-only (no Go backend)"
    echo " - API Server: Not available"
fi
echo " - Streamlit Port: 7860 (public)"
echo " - Timezone: $TZ"
echo ""

# 啟動 Streamlit
echo "Starting Streamlit..."
exec streamlit run /app/streamlit/app.py \
    --server.port=7860 \
    --server.address=0.0.0.0 \
    --server.headless=true \
    --server.enableCORS=false \
    --server.enableXsrfProtection=false