fix:优化配置文件自动加载逻辑

pull/372/head
lifei6671 2018-09-19 14:29:25 +08:00
parent 3aa703d479
commit 7e17b5ef99
1 changed files with 6 additions and 2 deletions

View File

@ -417,19 +417,23 @@ func RegisterAutoLoadConfig() {
if ev.IsModify() { if ev.IsModify() {
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil { if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
beego.Error("An error occurred ->", err) beego.Error("An error occurred ->", err)
break continue
} }
RegisterCache() RegisterCache()
RegisterLogger("") RegisterLogger("")
beego.Info("配置文件已加载 ->", conf.ConfigurationFile) beego.Info("配置文件已加载 ->", conf.ConfigurationFile)
} else if ev.IsRename() {
watcher.WatchFlags(conf.ConfigurationFile, fsnotify.FSN_MODIFY|fsnotify.FSN_RENAME)
} }
beego.Info(ev.String())
case err := <-watcher.Error: case err := <-watcher.Error:
beego.Error("配置文件监控器错误 ->", err) beego.Error("配置文件监控器错误 ->", err)
} }
} }
}() }()
err = watcher.Watch(conf.ConfigurationFile) err = watcher.WatchFlags(conf.ConfigurationFile, fsnotify.FSN_MODIFY|fsnotify.FSN_RENAME)
if err != nil { if err != nil {
beego.Error("监控配置文件失败 ->",err) beego.Error("监控配置文件失败 ->",err)