mirror of
https://github.com/beego/bee.git
synced 2024-11-26 01:11:30 +00:00
Update
This commit is contained in:
parent
723ddb4060
commit
78a6597edb
9
watch.go
9
watch.go
@ -30,6 +30,7 @@ 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")
|
||||||
|
Loading…
Reference in New Issue
Block a user