Compare commits
3 Commits
a2061d124f
...
f3e1b37b2d
Author | SHA1 | Date | |
---|---|---|---|
f3e1b37b2d | |||
cf1ad2ed4b | |||
|
4ebc8d6a14 |
@ -54,10 +54,17 @@ func main() {
|
|||||||
// channel closed
|
// channel closed
|
||||||
return
|
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
|
// send reload channel
|
||||||
reloadChan <- struct{}{}
|
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:
|
case err, ok := <-watcher.Errors:
|
||||||
if !ok {
|
if !ok {
|
||||||
// channel closed
|
// channel closed
|
||||||
@ -113,8 +120,8 @@ func runService(reload <-chan struct{}) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if time.Since(lastReload).Seconds() < float64(2*time.Second) {
|
if time.Since(lastReload).Seconds() < (2 * time.Second).Seconds() {
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
lastReload = time.Now()
|
lastReload = time.Now()
|
||||||
|
Loading…
Reference in New Issue
Block a user