From 3ac101606422f010b8b33fb6d3771539923f230a Mon Sep 17 00:00:00 2001 From: David Calavera Date: Thu, 10 Dec 2015 18:35:10 -0500 Subject: [PATCH] Allow to set daemon and server configurations in a file. Read configuration after flags making this the priority: 1- Apply configuration from file. 2- Apply configuration from flags. Reload configuration when a signal is received, USR2 in Linux: - Reload router if the debug configuration changes. - Reload daemon labels. - Reload cluster discovery. Signed-off-by: David Calavera --- discovery/backends.go | 8 ++------ discovery/memory/memory.go | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/discovery/backends.go b/discovery/backends.go index 875a26c..f150115 100644 --- a/discovery/backends.go +++ b/discovery/backends.go @@ -12,12 +12,8 @@ import ( var ( // Backends is a global map of discovery backends indexed by their // associated scheme. - backends map[string]Backend -) - -func init() { backends = make(map[string]Backend) -} +) // Register makes a discovery backend available by the provided scheme. // If Register is called twice with the same scheme an error is returned. @@ -42,7 +38,7 @@ func parse(rawurl string) (string, string) { // ParseAdvertise parses the --cluster-advertise daemon config which accepts // : or : -func ParseAdvertise(store, advertise string) (string, error) { +func ParseAdvertise(advertise string) (string, error) { var ( iface *net.Interface addrs []net.Addr diff --git a/discovery/memory/memory.go b/discovery/memory/memory.go index f389825..777a9a1 100644 --- a/discovery/memory/memory.go +++ b/discovery/memory/memory.go @@ -25,6 +25,7 @@ func Init() { // Initialize sets the heartbeat for the memory backend. func (s *Discovery) Initialize(_ string, heartbeat time.Duration, _ time.Duration, _ map[string]string) error { s.heartbeat = heartbeat + s.values = make([]string, 0) return nil }