diff pkg/config/config.go @ 1000:14425e35e3c2 persistent-import-queue

Wait with start of import queue until configuration is fully loaded.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 22 Oct 2018 17:16:02 +0200
parents 2818ad6c7d32
children a244b18cb916
line wrap: on
line diff
--- a/pkg/config/config.go	Mon Oct 22 16:55:05 2018 +0200
+++ b/pkg/config/config.go	Mon Oct 22 17:16:02 2018 +0200
@@ -156,7 +156,26 @@
 	str("proxy-prefix", "", `URL prefix of proxy. Defaults to "http://${web-host}:${web-port}"`)
 
 	str("tmp-dir", "", "Temp directory of gemma server. Defaults to system temp directory.")
+}
 
+var (
+	configCond  = sync.NewCond(new(sync.Mutex))
+	configReady bool
+)
+
+func Ready() {
+	configCond.L.Lock()
+	defer configCond.L.Unlock()
+	configReady = true
+	configCond.Broadcast()
+}
+
+func WaitReady() {
+	configCond.L.Lock()
+	defer configCond.L.Unlock()
+	for !configReady {
+		configCond.Wait()
+	}
 }
 
 func initConfig() {