fix(orbit): sync logs header directly with DB running state
This commit is contained in:
+2
-2
@@ -512,8 +512,6 @@ func deployAppAsync(appID string) {
|
|||||||
containerID, imageTag, intPort, buildType, time.Now().Unix(), appID).Exec()
|
containerID, imageTag, intPort, buildType, time.Now().Unix(), appID).Exec()
|
||||||
|
|
||||||
saveDeploymentRecord(appID, "success", int(time.Since(startTime).Seconds()), logBuf.String())
|
saveDeploymentRecord(appID, "success", int(time.Since(startTime).Seconds()), logBuf.String())
|
||||||
// Clear in-memory build log — live container logs will be served from Docker from now on
|
|
||||||
time.Sleep(2 * time.Second) // let any pending log reads finish
|
|
||||||
orbitBuildLogs.Delete(appID)
|
orbitBuildLogs.Delete(appID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,6 +831,7 @@ func handleOrbitAppLogs(w http.ResponseWriter, r *http.Request, appID string) {
|
|||||||
w.Header().Set("X-App-Status", app.Status)
|
w.Header().Set("X-App-Status", app.Status)
|
||||||
|
|
||||||
// 1. If currently building: serve live in-memory build log
|
// 1. If currently building: serve live in-memory build log
|
||||||
|
if app.Status == "building" {
|
||||||
if val, ok := orbitBuildLogs.Load(appID); ok {
|
if val, ok := orbitBuildLogs.Load(appID); ok {
|
||||||
buf := val.(*bytes.Buffer)
|
buf := val.(*bytes.Buffer)
|
||||||
logText := buf.String()
|
logText := buf.String()
|
||||||
@@ -840,6 +839,7 @@ func handleOrbitAppLogs(w http.ResponseWriter, r *http.Request, appID string) {
|
|||||||
w.Write([]byte(logText))
|
w.Write([]byte(logText))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. If running: stream live container stdout/stderr
|
// 2. If running: stream live container stdout/stderr
|
||||||
if app.Status == "running" && app.ContainerID != "" {
|
if app.Status == "running" && app.ContainerID != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user