1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-21 13:23:07 +01:00

chore: send server id by loading system info (#2936)

This commit is contained in:
Amir Raminfar
2024-05-07 18:18:51 -07:00
committed by GitHub
parent d37c1395cb
commit 8a2640cd6b
9 changed files with 116 additions and 60 deletions

15
main.go
View File

@@ -83,7 +83,7 @@ func main() {
}
srv := createServer(args, clients)
go doStartEvent(args)
go doStartEvent(args, clients)
go func() {
log.Infof("Accepting connections on %s", srv.Addr)
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
@@ -104,7 +104,7 @@ func main() {
log.Debug("shutdown complete")
}
func doStartEvent(arg args) {
func doStartEvent(arg args, clients map[string]docker.Client) {
if arg.NoAnalytics {
log.Debug("Analytics disabled.")
return
@@ -115,6 +115,17 @@ func doStartEvent(arg args) {
Version: version,
}
if client, ok := clients["localhost"]; ok {
event.ServerID = client.SystemInfo().ID
event.ServerVersion = client.SystemInfo().ServerVersion
} else {
for _, client := range clients {
event.ServerID = client.SystemInfo().ID
event.ServerVersion = client.SystemInfo().ServerVersion
break
}
}
if err := analytics.SendBeacon(event); err != nil {
log.Debug(err)
}