mirror of https://github.com/shunfei/cronsun
csctl: for cmd tools, watch configuration files is unnecessary.
parent
a7a908bd83
commit
b542d52b86
|
@ -33,7 +33,7 @@ func main() {
|
||||||
}
|
}
|
||||||
log.SetLogger(logger.Sugar())
|
log.SetLogger(logger.Sugar())
|
||||||
|
|
||||||
if err = cronsun.Init(*confFile); err != nil {
|
if err = cronsun.Init(*confFile, true); err != nil {
|
||||||
log.Errorf(err.Error())
|
log.Errorf(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func main() {
|
||||||
}
|
}
|
||||||
log.SetLogger(logger.Sugar())
|
log.SetLogger(logger.Sugar())
|
||||||
|
|
||||||
if err = cronsun.Init(*confFile); err != nil {
|
if err = cronsun.Init(*confFile, true); err != nil {
|
||||||
log.Errorf(err.Error())
|
log.Errorf(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ var (
|
||||||
_Uid int
|
_Uid int
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(baseConfFile string) (err error) {
|
func Init(baseConfFile string, watchConfiFile bool) (err error) {
|
||||||
if initialized {
|
if initialized {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func Init(baseConfFile string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init config
|
// 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)
|
return fmt.Errorf("Init Config failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
conf/conf.go
10
conf/conf.go
|
@ -22,7 +22,7 @@ var (
|
||||||
exitChan = make(chan struct{})
|
exitChan = make(chan struct{})
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(confFile string) error {
|
func Init(confFile string, watchConfiFile bool) error {
|
||||||
if initialized {
|
if initialized {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,13 @@ func Init(confFile string) error {
|
||||||
if err := Config.parse(confFile); err != nil {
|
if err := Config.parse(confFile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := Config.watch(confFile); err != nil {
|
|
||||||
return err
|
if watchConfiFile {
|
||||||
|
if err := Config.watch(confFile); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized = true
|
initialized = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue