CLIProxyAPIPlus / entrypoint.sh
kines9661's picture
Upload 11 files
96e1383 verified
#!/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