diff --git a/bin/node/server.go b/bin/node/server.go index 2ca3080..b1a8693 100644 --- a/bin/node/server.go +++ b/bin/node/server.go @@ -33,7 +33,7 @@ func main() { } log.SetLogger(logger.Sugar()) - if err = cronsun.Init(*confFile); err != nil { + if err = cronsun.Init(*confFile, true); err != nil { log.Errorf(err.Error()) return } diff --git a/bin/web/server.go b/bin/web/server.go index 754ec30..1d56e15 100644 --- a/bin/web/server.go +++ b/bin/web/server.go @@ -34,7 +34,7 @@ func main() { } log.SetLogger(logger.Sugar()) - if err = cronsun.Init(*confFile); err != nil { + if err = cronsun.Init(*confFile, true); err != nil { log.Errorf(err.Error()) return } diff --git a/common.go b/common.go index 9ac7c23..baeafd4 100644 --- a/common.go +++ b/common.go @@ -14,7 +14,7 @@ var ( _Uid int ) -func Init(baseConfFile string) (err error) { +func Init(baseConfFile string, watchConfiFile bool) (err error) { if initialized { return } @@ -25,7 +25,7 @@ func Init(baseConfFile string) (err error) { } // init config - if err = conf.Init(baseConfFile); err != nil { + if err = conf.Init(baseConfFile, watchConfiFile); err != nil { return fmt.Errorf("Init Config failed: %s", err) } diff --git a/conf/conf.go b/conf/conf.go index ede3a9c..cd7d0d7 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -22,7 +22,7 @@ var ( exitChan = make(chan struct{}) ) -func Init(confFile string) error { +func Init(confFile string, watchConfiFile bool) error { if initialized { return nil } @@ -30,9 +30,13 @@ func Init(confFile string) error { if err := Config.parse(confFile); err != nil { return err } - if err := Config.watch(confFile); err != nil { - return err + + if watchConfiFile { + if err := Config.watch(confFile); err != nil { + return err + } } + initialized = true return nil }