beego/bee

AutoBuild is not being fired

ogero opened this issue · 1 comments

ogero commented

Go: go version go1.7.3 windows/amd64
OS: Windows 7 Ultimate SP1 x64
BeeGo: beego 1.7.1 / bee v1.6.2
Command: bee run -downdoc=true -gendoc=true.
Output:

______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2017/02/11 16:24:07 INFO     ? 0001 Using 'beego-demo' as 'appname'
2017/02/11 16:24:08 INFO     ? 0002 Loading default configuration...
2017/02/11 16:24:08 INFO     ? 0003 Initializing watcher...
2017/02/11 16:24:08 INFO     ? 0004 Watching: G:\gopath\src\beego-demo/controllers
2017/02/11 16:24:08 INFO     ? 0005 Watching: G:\gopath\src\beego-demo
2017/02/11 16:24:08 INFO     ? 0006 Watching: G:\gopath\src\beego-demo/models
2017/02/11 16:24:08 INFO     ? 0007 Watching: G:\gopath\src\beego-demo/routers
2017/02/11 16:24:08 INFO     ? 0008 Watching: G:\gopath\src\beego-demo/tests
2017/02/11 16:24:09 INFO     ? 0009 Generating the docs...
2017/02/11 16:24:09 SUCCESS  ? 0010 Docs generated!
2017/02/11 16:24:10 SUCCESS  ? 0011 Built Successfully!
2017/02/11 16:24:10 INFO     ? 0012 Restarting 'beego-demo'...
2017/02/11 16:24:10 SUCCESS  ? 0013 './beego-demo' is running...
2017/02/11 16:24:10 [I] [router.go:229] G:\gopath\src\beego-demo\controllers no changed
2017/02/11 16:24:17 [I] [asm_amd64.s:2086] http server Running on http://:9090
2017/02/11 16:24:36 INFO     ? 0014 Event fired: "G:\\gopath\\src\\beego-demo\\main.go": WRITE
2017/02/11 16:24:36 INFO     ? 0015 Skipping: "G:\\gopath\\src\\beego-demo\\main.go": WRITE
2017/02/11 16:24:53 INFO     ? 0016 Event fired: "G:\\gopath\\src\\beego-demo\\main.go": WRITE
2017/02/11 16:24:53 INFO     ? 0017 Skipping: "G:\\gopath\\src\\beego-demo\\main.go": WRITE

The main.go file changes are detected and correctly debounced, but the AutoBuild function is never called.
The culprit is this return.
So i wonder... if time.Sleep function is guaranteed to roughly sleep for the requested time, why is there that awful extra check after the Sleep call?
Also, the repeated call to time.Now to perform the After operation, is wrong, as the previous call value sould have been used.
Everything seems to work fine after taking all the fuzz away from that go func() to

go func() {
	// Wait 1s before autobuild until there is no file change.
	scheduleTime = time.Now().Add(1 * time.Second)
	AutoBuild(files, isgenerate)
}()

See #352

PR merged.