Skip to content

Commit

Permalink
Use default config if none exist at startup
Browse files Browse the repository at this point in the history
Also adds some glog flush() to ensure we see more of the log output
  • Loading branch information
bowei committed Feb 19, 2017
1 parent f96772f commit df023ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/dns/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type Config struct {

func NewDefaultConfig() *Config {
return &Config{
Federations: make(map[string]string),
Federations: map[string]string{},
StubDomains: map[string][]string{},
}
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/dnsmasq/nanny.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,12 @@ type RunNannyOpts struct {

// RunNanny runs the nanny and handles configuration updates.
func RunNanny(sync config.Sync, opts RunNannyOpts) {
defer glog.Flush()

currentConfig, err := sync.Once()
if err != nil {
glog.Fatalf("Error getting initial config: %v", err)
glog.Errorf("Error getting initial config, using default: %v", err)
currentConfig = config.NewDefaultConfig()
}

nanny := &Nanny{Exec: opts.DnsmasqExec}
Expand All @@ -175,6 +178,7 @@ func RunNanny(sync config.Sync, opts RunNannyOpts) {
for {
select {
case status := <-nanny.ExitChannel:
glog.Flush()
glog.Fatalf("dnsmasq exited: %v", status)
break
case currentConfig = <-configChan:
Expand Down

0 comments on commit df023ff

Please sign in to comment.