Compare commits

...

3 Commits

Author SHA1 Message Date
Jay
f3e1b37b2d Merge pull request 'develop' (#7) from develop into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Reviewed-on: #7
2021-07-07 16:22:23 +00:00
Jay
cf1ad2ed4b Merge pull request 'fix skip condition' (#6) from feature/fix-watch into develop
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: #6
2021-07-07 16:22:05 +00:00
Jay
4ebc8d6a14 fix skip condition
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-07-08 00:21:40 +08:00

View File

@ -54,10 +54,17 @@ func main() {
// channel closed
return
}
if event.Op&fsnotify.Write == fsnotify.Write {
// 改成有變動就reload
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Chmod == fsnotify.Chmod {
// 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
@ -113,8 +120,8 @@ func runService(reload <-chan struct{}) {
}
return
}
if time.Since(lastReload).Seconds() < float64(2*time.Second) {
break
if time.Since(lastReload).Seconds() < (2 * time.Second).Seconds() {
continue
}
lastReload = time.Now()