1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-27 23:46:39 +01:00

chore: logs swarm mode to beacon (#2918)

This commit is contained in:
Amir Raminfar
2024-04-26 14:30:32 -07:00
committed by GitHub
parent 7fb4dcce77
commit d7079c36e4
8 changed files with 60 additions and 127 deletions

View File

@@ -42,6 +42,7 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
allContainers := make([]docker.Container, 0)
events := make(chan docker.ContainerEvent)
stats := make(chan docker.ContainerStat)
hasSwarm := false
for _, store := range h.stores {
if containers, err := store.List(); err == nil {
@@ -55,6 +56,10 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
}
store.SubscribeStats(ctx, stats)
store.Subscribe(ctx, events)
if store.Client().IsSwarmMode() {
hasSwarm = true
}
}
defer func() {
@@ -67,6 +72,8 @@ func (h *handler) streamEvents(w http.ResponseWriter, r *http.Request) {
log.Errorf("error writing containers to event stream: %v", err)
}
b.RunningContainers = len(allContainers)
b.IsSwarmMode = hasSwarm
f.Flush()
if !h.config.NoAnalytics {

View File

@@ -59,6 +59,10 @@ func (m *MockedClient) Host() *docker.Host {
return args.Get(0).(*docker.Host)
}
func (m *MockedClient) IsSwarmMode() bool {
return false
}
func createHandler(client docker.Client, content fs.FS, config Config) *chi.Mux {
if client == nil {
client = new(MockedClient)