diff --git a/confd.go b/confd.go index e0ccbf1af..cc7ee0204 100644 --- a/confd.go +++ b/confd.go @@ -7,6 +7,7 @@ import ( "os/signal" "runtime" "syscall" + "time" "github.com/kelseyhightower/confd/backends" "github.com/kelseyhightower/confd/log" @@ -38,6 +39,17 @@ func main() { os.Exit(0) } + if config.SyncFirst { + for { + if err := template.Process(config.TemplateConfig); err != nil { + log.Error(err.Error()) + time.Sleep(5 * time.Second) + } else { + break + } + } + } + stopChan := make(chan bool) doneChan := make(chan bool) errChan := make(chan error, 10) diff --git a/config.go b/config.go index 75172d3dd..855b60f53 100644 --- a/config.go +++ b/config.go @@ -31,6 +31,7 @@ type Config struct { PrintVersion bool ConfigFile string OneTime bool + SyncFirst bool } var config Config @@ -70,6 +71,7 @@ func init() { flag.StringVar(&config.Username, "username", "", "the username to authenticate as (only used with vault and etcd backends)") flag.StringVar(&config.Password, "password", "", "the password to authenticate with (only used with vault and etcd backends)") flag.BoolVar(&config.Watch, "watch", false, "enable watch support") + flag.BoolVar(&config.SyncFirst, "sync-first", false, "sync template first") } // initConfig initializes the confd configuration by first setting defaults,