Skip to content

Commit eff41cc

Browse files
Stream periodic infrastructure snapshots
1 parent f19b6e0 commit eff41cc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cmd/stackhost/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,12 @@ func (a *app) eventsStream(w http.ResponseWriter, r *http.Request) {
519519
fmt.Fprintf(w, "data: %s\n\n", b)
520520
flusher.Flush()
521521
case <-ticker.C:
522-
fmt.Fprint(w, "event: heartbeat\ndata: {}\n\n")
522+
infra := any(map[string]any{"available": false, "message": "Docker não está conectado."})
523+
if a.docker != nil {
524+
infra = a.docker.Snapshot(r.Context())
525+
}
526+
b, _ := json.Marshal(map[string]any{"event": "infrastructure.updated", "data": infra, "at": time.Now().UTC().Format(time.RFC3339)})
527+
fmt.Fprintf(w, "data: %s\n\n", b)
523528
flusher.Flush()
524529
}
525530
}

0 commit comments

Comments
 (0)