8000 Realtime rebuild by k0kubun · Pull Request #591 · revel/revel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Realtime rebuild #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 13, 2014
Merged

Realtime rebuild #591

merged 7 commits into from
Sep 13, 2014

Conversation

k0kubun
Copy link
Contributor
@k0kubun k0kubun commented Apr 29, 2014

Problem

Because Revel receives file change events when receiving HTTP requests,
Revel does not rebuild an application until a browser reload or something.

Solution

But you can start to rebuild the application when the file is changed if you watch file change events in real time.
So I created goroutine to receive them.

Because a select statement without default case waits until receiving events, its performance didn't become worse.

@pushrax
Copy link
Contributor
pushrax commented Apr 29, 2014

This is done by design, to prevent rebuilding multiple times when saving multiple files (or saving a file multi 8000 ple times).

@revel/core should we make it configurable?

@brendensoares
Copy link
Member

@pushrax a configurable option would be nice. I could see this being acceptable in dev mode, but not production.

@brendensoares brendensoares added this to the v0.11 milestone May 7, 2014
@k0kubun
Copy link
Contributor Author
k0kubun commented May 8, 2014

I see.
I'll change this to a configurable optional feature later.

@brendensoares
Copy link
Member

Sounds good @k0kubun. We may add it ourselves for the next release if you aren't able to by then, so please keep us up to date on your progress.

@k0kubun
Copy link
Contributor Author
k0kubun commented May 9, 2014

Thanks to accept the feature request.
I've done it. fa1469a

I added rebuild.eager option to enable this feature, and it is set to false by default.

if !strings.HasPrefix(path.Base(ev.Name), ".") {
if dl, ok := listener.(DiscerningListener); ok {
if !dl.WatchFile(ev.Name) || ev.IsAttrib() {
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This nesting has gotten too deep, I think this should be extracted into a method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. It became hard to read.
I splitted the logic into w.rebuildRequired() in d451f28

@pushrax
Copy link
Contributor
pushrax commented May 9, 2014

We're getting close here 🍰

@pedromorgan
Copy link
Member

This will probably solve my problem with working on "jobs related code", ie not http stuff..

@FrancisVarga
Copy link

+1

@k0kubun
Copy link
Contributor Author
k0kubun commented Sep 13, 2014

@k0kubun instead of rebuild.eager can we do watcher.eager? No need to add new root config attributes.

Also, is there a better word than eager? Seems odd. :)

That's true. Since this option is created to decide whether harness rebuilds eagerly or not, how about watcher.rebuild_eagerly?

@brendensoares
Copy link
Member

@k0kubun or watcher.mode = "normal|eager"?

@k0kubun
Copy link
Contributor Author
k0kubun commented Sep 13, 2014

I rebased to resolve a conflict but made CI failed. Sorry...

@k0kubun or watcher.mode = "normal|eager"?

Thank you for nice suggestion! It seems more natural than my idea.

@brendensoares
Copy link
Member

http://godoc.org/gopkg.in/fsnotify.v1#Watcher

Watcher has no Event or Error. Why did you change those lines? Perhaps that was the old version?

gopkg.in/fsnotify.v1
github.com/revel/revel

github.com/revel/revel

_./watcher.go:149: watcher.Event undefined (type *fsnotify.Watcher has no field or method Event)
./watcher.go:156: watcher.Error undefined (type *fsnotify.Watcher has no field or method Error)
_
./watcher.go:176: watcher.Event undefined (type *fsnotify.Watcher has no field or method Event)
./watcher.go:181: watcher.Error undefined (type *fsnotify.Watcher has no field or method Error)
./watcher.go:212: undefined: fsnotify.FileEvent

@k0kubun
8000 Copy link
Contributor Author
k0kubun commented Sep 13, 2014

Perhaps that was the old version?

I think so. I fixed some error in edd4773, but still have some problems.
http://godoc.org/gopkg.in/fsnotify.v1 and https://godoc.org/github.com/howeyc/fsnotify have many API differences. I have to change some implementation from an old version.

@brendensoares
Copy link
Member

TravisCI is passing. Do I have your green light to merge?

@k0kubun
Copy link
Contributor Author
k0kubun commented Sep 13, 2014

I changed the option to enable this feature. 79abc3f
If this change is OK, please merge this pull request :)

brendensoares added a commit that referenced this pull request Sep 13, 2014
@brendensoares brendensoares merged commit 05474e2 into revel:develop Sep 13, 2014
@k0kubun k0kubun deleted the realtime_rebuild branch September 13, 2014 15:58
@pushrax
Copy link
Contributor
pushrax commented Sep 13, 2014

How about watcher.mode = 'deferred' or 'eager'?

@pushrax
Copy link
Contributor
pushrax commented Sep 13, 2014

Oh, it's merged already. Will push another commit to fix up a spelling mistake.

@k0kubun
Copy link
Contributor Author
k0kubun commented Sep 13, 2014

Thank you 💓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0