Files
xiaolajiaoyyds c231e2e78e fix: add missing cmd/ entry points
Restore cmd/server/, cmd/openai-worker/, cmd/grok-worker/
that were accidentally excluded during initial copy.
2026-03-22 04:12:51 +08:00

43 lines
1.1 KiB
Go
Raw Permalink 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.
package main
import (
"os"
"github.com/gin-gonic/gin"
"github.com/xiaolajiaoyyds/regplatformm/internal/worker"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "7860" // HuggingFace 默认端口
}
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
// 处理端点 — 带并发限流(超限返回 503,CF Worker 自动转发下一节点)
handler := []gin.HandlerFunc{worker.ConcurrencyLimiter(), worker.OpenAIProtocolRegisterHandler}
r.POST("/api/v1/process", handler...)
// 兼容 VPS 直连隧道域名(不经过 CF Worker 路由重写时路径为 /openai/process)
r.POST("/openai/process", handler...)
// 健康检查(精简响应,仅暴露 CF Worker 需要的最小字段)
r.GET("/health", func(c *gin.Context) {
c.JSON(200, gin.H{"status": "ok", "concurrency": worker.ConcurrencyStats()})
})
// 根路径
r.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"model": "distilbert-base-uncased",
"task": "text-classification",
"framework": "onnxruntime",
"version": "1.2.0",
"status": "ready",
})
})
r.Run(":" + port)
}