Update GLPI-Knowledge
All checks were successful
release-tag / release-image (push) Successful in 1m35s
All checks were successful
release-tag / release-image (push) Successful in 1m35s
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/example/glpi-ai-agent/internal/config"
|
||||
"github.com/example/glpi-ai-agent/internal/contextdata"
|
||||
"github.com/example/glpi-ai-agent/internal/glpi"
|
||||
"github.com/example/glpi-ai-agent/internal/glpikb"
|
||||
"github.com/example/glpi-ai-agent/internal/knowledge"
|
||||
"github.com/example/glpi-ai-agent/internal/learning"
|
||||
"github.com/example/glpi-ai-agent/internal/metrics"
|
||||
@@ -84,6 +85,18 @@ func main() {
|
||||
}
|
||||
m := metrics.New()
|
||||
m.SetKnowledgeDocs(k.Count())
|
||||
if cfg.GLPIKBEnabled {
|
||||
kbSync := glpikb.New(cfg, g, k, m)
|
||||
if err := kbSync.LoadCache(ctx); err != nil {
|
||||
slog.Warn("GLPI knowledge cache unavailable", "error", err)
|
||||
}
|
||||
syncCtx, syncCancel := context.WithTimeout(ctx, maxDuration(cfg.GLPITimeout*3, 30*time.Second))
|
||||
if err := kbSync.Sync(syncCtx); err != nil {
|
||||
slog.Error("initial GLPI knowledge base sync failed; continuing with local/cache knowledge", "error", err)
|
||||
}
|
||||
syncCancel()
|
||||
kbSync.Start(ctx)
|
||||
}
|
||||
q := queue.New(cfg.QueueSize)
|
||||
var kuma *uptimekuma.Client
|
||||
if cfg.UptimeKumaEnabled {
|
||||
@@ -111,3 +124,10 @@ func main() {
|
||||
_ = srv.Shutdown(shutdownCtx)
|
||||
slog.Info("shutdown complete")
|
||||
}
|
||||
|
||||
func maxDuration(a, b time.Duration) time.Duration {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user