Mercurial > gemma
changeset 3246:64324aaeb1fb
Made logging of waht is registered to the scheduler and the import queue more deterministic.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 13 May 2019 09:41:35 +0200 |
parents | 60f25cbe77fb |
children | 35c124338f36 |
files | cmd/gemma/main.go pkg/imports/queue.go pkg/scheduler/scheduler.go |
diffstat | 3 files changed, 37 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd/gemma/main.go Mon May 13 09:15:20 2019 +0200 +++ b/cmd/gemma/main.go Mon May 13 09:41:35 2019 +0200 @@ -31,6 +31,8 @@ "gemma.intevation.de/gemma/pkg/config" "gemma.intevation.de/gemma/pkg/controllers" "gemma.intevation.de/gemma/pkg/geoserver" + "gemma.intevation.de/gemma/pkg/imports" + "gemma.intevation.de/gemma/pkg/scheduler" ) func prepareSessionStore() { @@ -56,6 +58,10 @@ // Do GeoServer setup in background. geoserver.Reconfigure(geoserver.PrepareGeoServer) + // Log what it is rgistered to the import queue and scheduler. + imports.LogImportKindNames() + scheduler.LogActionNames() + m := mux.NewRouter() controllers.BindRoutes(m)
--- a/pkg/imports/queue.go Mon May 13 09:15:20 2019 +0200 +++ b/pkg/imports/queue.go Mon May 13 09:41:35 2019 +0200 @@ -20,6 +20,7 @@ "fmt" "log" "runtime/debug" + "sort" "strings" "sync" "time" @@ -225,6 +226,15 @@ return iqueue.importKindNames() } +// LogImportKindNames logs a list of importer types registered +// to the global import queue. +func LogImportKindNames() { + kinds := ImportKindNames() + sort.Strings(kinds) + log.Printf("info: registered import kinds: %s", + strings.Join(kinds, ", ")) +} + // HasImportKindName checks if the import queue supports a given kind. func HasImportKindName(kind string) bool { return iqueue.hasImportKindName(kind) @@ -241,7 +251,6 @@ // This a good candidate to be called in a init function for // a particular JobCreator. func RegisterJobCreator(kind JobKind, jc JobCreator) { - log.Printf("info: register import job creator for kind '%s'\n", kind) iqueue.registerJobCreator(kind, jc) }
--- a/pkg/scheduler/scheduler.go Mon May 13 09:15:20 2019 +0200 +++ b/pkg/scheduler/scheduler.go Mon May 13 09:41:35 2019 +0200 @@ -15,6 +15,8 @@ import ( "log" + "sort" + "strings" "sync" "github.com/robfig/cron" @@ -293,8 +295,26 @@ return s.actions[name] } +func LogActionNames() { + names := global.actionNames() + sort.Strings(names) + log.Printf("info: actions registered to scheduler: %s\n", + strings.Join(names, ", ")) +} + +func (s *scheduler) actionNames() []string { + s.mu.Lock() + defer s.mu.Unlock() + names := make([]string, len(s.actions)) + var i int + for k := range s.actions { + names[i] = k + i++ + } + return names +} + func (s *scheduler) registerAction(name string, action Action) { - log.Printf("info: register action '%s' in scheduler.", name) s.mu.Lock() defer s.mu.Unlock() s.actions[name] = action