Compare commits
No commits in common. "cf1ad2ed4bdbda76dd685ef700a8d48c2665c10d" and "3004d0837d4422b94df4a47c57ef05bf2e834356" have entirely different histories.
cf1ad2ed4b
...
3004d0837d
@ -54,17 +54,10 @@ func main() {
|
|||||||
// channel closed
|
// channel closed
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 改成有變動就reload
|
if event.Op&fsnotify.Write == fsnotify.Write {
|
||||||
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
|
||||||
@ -120,8 +113,8 @@ func runService(reload <-chan struct{}) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if time.Since(lastReload).Seconds() < (2 * time.Second).Seconds() {
|
if time.Since(lastReload).Seconds() < float64(2*time.Second) {
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
lastReload = time.Now()
|
lastReload = time.Now()
|
||||||
|
Loading…
Reference in New Issue
Block a user