feat: dashboard

This commit is contained in:
tao.chen
2026-09-01 10:13:33 +08:00
parent 208eb7f242
commit dfe7f85977
7 changed files with 988 additions and 6 deletions
+15 -1
View File
@@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"log"
"net/http"
"time"
"github.com/gin-gonic/gin"
@@ -17,6 +18,9 @@ func main() {
log.Fatalf("加载配置文件失败: %v", err)
}
// 初始化 dashboard 状态(必须在 startBuildWorker 之前,否则 worker 回调为 nil
dashboard = newDashboard()
//gin.SetMode(gin.ReleaseMode)
r := gin.New()
r.Use(gin.Recovery())
@@ -29,10 +33,20 @@ func main() {
startBuildWorker()
// Webhook 入口
r.POST("/webhook", handleWebhook)
// Dashboard 静态资源 + 页面
r.GET("/", handleIndex)
r.StaticFS("/static", http.FS(staticSubFS()))
// Dashboard JSON API
r.GET("/api/queue", handleQueue)
r.GET("/api/history", handleHistory)
listenAddr := fmt.Sprintf(":%d", *portFlag)
log.Printf("GitLab Webhook 服务已启动 (队列模式 + 3 分钟冷却去重),监听端口 %d ...\n", *portFlag)
log.Printf("GitLab Webhook 服务已启动 (队列模式 + 3 分钟冷却去重), 监听端口 %d ...\n", *portFlag)
log.Printf("Dashboard: http://localhost:%d/\n", *portFlag)
if err := r.Run(listenAddr); err != nil {
log.Fatalf("服务启动失败: %v", err)