1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 15:10:54 +00:00
This commit is contained in:
Unknown 2013-12-09 11:11:26 -05:00
parent 723ddb4060
commit 78a6597edb

View File

@ -27,9 +27,10 @@ import (
) )
var ( var (
cmd *exec.Cmd cmd *exec.Cmd
state sync.Mutex state sync.Mutex
eventTime = make(map[string]int64) eventTime = make(map[string]int64)
buildPeriod time.Time
) )
func NewWatcher(paths []string) { func NewWatcher(paths []string) {
@ -53,6 +54,12 @@ func NewWatcher(paths []string) {
continue continue
} }
// Prevent duplicated builds.
if buildPeriod.Add(1 * time.Second).After(time.Now()) {
continue
}
buildPeriod = time.Now()
mt := getFileModTime(e.Name) mt := getFileModTime(e.Name)
if t := eventTime[e.Name]; mt == t { if t := eventTime[e.Name]; mt == t {
ColorLog("[SKIP] # %s #\n", e.String()) 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 ColorLog("[WARN] %s\n", err.Error()) // No need to exit here
} }
} }
time.Sleep(500 * time.Millisecond)
}() }()
ColorLog("[INFO] Initializing watcher...\n") ColorLog("[INFO] Initializing watcher...\n")