mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
Update
This commit is contained in:
parent
723ddb4060
commit
78a6597edb
15
watch.go
15
watch.go
@ -27,9 +27,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
cmd *exec.Cmd
|
||||
state sync.Mutex
|
||||
eventTime = make(map[string]int64)
|
||||
cmd *exec.Cmd
|
||||
state sync.Mutex
|
||||
eventTime = make(map[string]int64)
|
||||
buildPeriod time.Time
|
||||
)
|
||||
|
||||
func NewWatcher(paths []string) {
|
||||
@ -53,6 +54,12 @@ func NewWatcher(paths []string) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Prevent duplicated builds.
|
||||
if buildPeriod.Add(1 * time.Second).After(time.Now()) {
|
||||
continue
|
||||
}
|
||||
buildPeriod = time.Now()
|
||||
|
||||
mt := getFileModTime(e.Name)
|
||||
if t := eventTime[e.Name]; mt == t {
|
||||
ColorLog("[SKIP] # %s #\n", e.String())
|
||||
@ -69,8 +76,6 @@ func NewWatcher(paths []string) {
|
||||
ColorLog("[WARN] %s\n", err.Error()) // No need to exit here
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}()
|
||||
|
||||
ColorLog("[INFO] Initializing watcher...\n")
|
||||
|
Loading…
Reference in New Issue
Block a user