Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ RUN chown -R appuser:appuser /root/
# 切换到非root用户
USER appuser

# 暴露端口
# 暴露端口(Render 会通过 PORT 环境变量指定)
EXPOSE 8002
EXPOSE 10000

# 健康检查
# 健康检查(使用环境变量 PORT)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:8002/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))" || exit 1
CMD node -e "const port = process.env.PORT || 8002; require('http').get('http://localhost:' + port + '/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))" || exit 1

# 启动应用
CMD ["./cursor2api-go"]
16 changes: 10 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {

// 禁用 Gin 的调试信息输出
gin.DisableConsoleColor()

// 创建路由器(使用 gin.New() 而不是 gin.Default() 以避免默认日志)
router := gin.New()

Expand All @@ -57,7 +57,7 @@ func main() {

// 创建HTTP服务器
server := &http.Server{
Addr: fmt.Sprintf(":%d", cfg.Port),
Addr: fmt.Sprintf("0.0.0.0:%d", cfg.Port),
Handler: router,
}

Expand Down Expand Up @@ -122,10 +122,14 @@ func printStartupBanner(cfg *config.Config) {
`
fmt.Println(banner)

fmt.Printf("🚀 服务地址: http://localhost:%d\n", cfg.Port)
fmt.Printf("📚 API 文档: http://localhost:%d/\n", cfg.Port)
fmt.Printf("💊 健康检查: http://localhost:%d/health\n", cfg.Port)
fmt.Printf("🔑 API 密钥: %s\n", maskAPIKey(cfg.APIKey))
host := os.Getenv("RENDER_EXTERNAL_URL")
if host == "" {
host = fmt.Sprintf("http://localhost:%d", cfg.Port)
}
fmt.Printf("🚀 服务地址: %s\n", host)
fmt.Printf("📚 API 文档: %s/\n", host)
fmt.Printf("💊 健康检查: %s/health\n", host)
fmt.Printf("🔑 API 密钥: %s\n", cfg.APIKey)

modelList := cfg.GetModels()
fmt.Printf("\n🤖 支持模型 (%d 个):\n", len(modelList))
Expand Down
27 changes: 27 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
- type: web
name: cursor2api-go
env: docker
plan: free
healthCheckPath: /health
envVars:
- key: PORT
value: 10000
- key: DEBUG
value: false
- key: API_KEY
generateValue: true
- key: MODELS
value: gpt-5.1,gpt-5,gpt-5-codex,gpt-5-mini,gpt-5-nano,gpt-4.1,gpt-4o,claude-3.5-sonnet,claude-3.5-haiku,claude-3.7-sonnet,claude-4-sonnet,claude-4.5-sonnet,claude-4-opus,claude-4.1-opus,gemini-2.5-pro,gemini-2.5-flash,gemini-3.0-pro,o3,o4-mini,deepseek-r1,deepseek-v3.1,kimi-k2-instruct,grok-3
- key: TIMEOUT
value: 60
- key: MAX_INPUT_LENGTH
value: 200000
- key: USER_AGENT
value: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
- key: UNMASKED_VENDOR_WEBGL
value: Google Inc. (Intel)
- key: UNMASKED_RENDERER_WEBGL
value: ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0, D3D11)
- key: SCRIPT_URL
value: https://cursor.com/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/a-4-a/c.js?i=0^&v=3^&h=cursor.com