csctl: for cmd tools, watch configuration files is unnecessary.

pull/69/head
Doflatango 2018-02-23 17:07:40 +08:00
parent a7a908bd83
commit b542d52b86
4 changed files with 11 additions and 7 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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)
}

View File

@ -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
}