chore: 统一本地服务器与远程仓库源码
- 合并 main 与 master 历史并以服务器结构为基线 - 保留迁移、数据保留、AWS 账单与部署安全能力 - 建立 SDD 规格和 CI 验证闭环
This commit is contained in:
commit
fd60361d93
460 files changed
+37492
-23871
No files matched your search
@@ -9,8 +9,8 @@ import (
|
||||
"time"
|
||||
|
||||
"ezops/middleware"
|
||||
"ezops/pkg/wshub"
|
||||
ezredis "ezops/pkg/redis"
|
||||
"ezops/pkg/wshub"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
@@ -53,12 +53,16 @@ func (h *WSPipelineLogHandler) StreamLog(c *gin.Context) {
|
||||
|
||||
// 首次发送:已有日志
|
||||
raw, _ := h.cache.Get(ctx, logKey)
|
||||
lastLen := 0
|
||||
if raw != "" {
|
||||
ws.WriteJSON(map[string]interface{}{"type": "init", "logs": raw})
|
||||
var entries []LogEntry
|
||||
if err := json.Unmarshal([]byte(raw), &entries); err == nil {
|
||||
lastLen = len(entries)
|
||||
}
|
||||
}
|
||||
|
||||
// 轮询新日志(500ms 间隔)
|
||||
lastLen := 0
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
|
||||
@@ -125,7 +129,7 @@ func (h *WSPipelineLogHandler) GetLogHistory(c *gin.Context) {
|
||||
// 先查 Redis(执行中)
|
||||
logKey := fmt.Sprintf("pipeline:run:%d:logs", uint(runID))
|
||||
ctx := c.Request.Context()
|
||||
|
||||
|
||||
raw, _ := h.cache.Get(ctx, logKey)
|
||||
if raw != "" && !strings.HasPrefix(raw, "[") {
|
||||
raw = "[]"
|
||||
@@ -137,7 +141,7 @@ func (h *WSPipelineLogHandler) GetLogHistory(c *gin.Context) {
|
||||
|
||||
// 查 DB(已完成)
|
||||
var logs string
|
||||
h.db.Table("ops_pipeline_runs").Where("id = ?", uint(runID)).Select("logs").Scan(&logs)
|
||||
h.db.Table("deploy_pipeline_runs").Where("id = ?", uint(runID)).Select("logs").Scan(&logs)
|
||||
if logs == "" {
|
||||
logs = "[]"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user