From 7e17b5ef9980d75cc79609db48e2d98865892f2d Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Wed, 19 Sep 2018 14:29:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=87=AA=E5=8A=A8=E5=8A=A0=E8=BD=BD=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/command.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/command.go b/commands/command.go index 06ef8ebd..208dd04a 100644 --- a/commands/command.go +++ b/commands/command.go @@ -417,19 +417,23 @@ func RegisterAutoLoadConfig() { if ev.IsModify() { if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil { beego.Error("An error occurred ->", err) - break + continue } RegisterCache() RegisterLogger("") 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: beego.Error("配置文件监控器错误 ->", err) + } } }() - err = watcher.Watch(conf.ConfigurationFile) + err = watcher.WatchFlags(conf.ConfigurationFile, fsnotify.FSN_MODIFY|fsnotify.FSN_RENAME) if err != nil { beego.Error("监控配置文件失败 ->",err)