1 Commits

Author SHA1 Message Date
root a2061d124f Merge pull request 'develop' (#5) from develop into master
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Reviewed-on: #5
2021-07-07 15:54:11 +00:00
+3 -10
View File
@@ -54,17 +54,10 @@ func main() {
// channel closed
return
}
// 改成有變動就reload
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Chmod == fsnotify.Chmod {
if event.Op&fsnotify.Write == fsnotify.Write {
// send reload channel
reloadChan <- struct{}{}
}
if event.Op&fsnotify.Remove == fsnotify.Remove {
watcher.Remove(cfgPath)
if err := watcher.Add(cfgPath); err != nil {
log.Fatal(err)
}
}
case err, ok := <-watcher.Errors:
if !ok {
// channel closed
@@ -120,8 +113,8 @@ func runService(reload <-chan struct{}) {
}
return
}
if time.Since(lastReload).Seconds() < (2 * time.Second).Seconds() {
continue
if time.Since(lastReload).Seconds() < float64(2*time.Second) {
break
}
lastReload = time.Now()