Skip to content
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

Do not call watchConfig() when not in watch mode #1773

Conversation

anthonyfok
Copy link
Member

See #1772


@spf13, does this look okay to you? :-)

@anthonyfok anthonyfok force-pushed the do-not-call-watchConfig-when-not-in-watch-mode branch 2 times, most recently from b427a19 to b51e412 Compare January 13, 2016 05:45
See gohugoio#1772

Also, force DisableLiveReload to true when running "hugo --watch"
(build-only non-server mode) to prevent livereload.ForceRefresh(),
which would end up blocking watchConfig() forever, from being called
because livereload.Initialize() is never called in this case.

This fixes the bug where "hugo --watch" could only reload config.toml
once before it gets stuck for good at livereload.ForceRefresh().

This is also consistent with Hugo's existing behaviour:
Non-server "hugo --watch" has never injected livereload.js
since the inception of the "watch" feature in Hugo v0.12.
@anthonyfok anthonyfok force-pushed the do-not-call-watchConfig-when-not-in-watch-mode branch from b51e412 to c0d7e99 Compare January 13, 2016 06:47
@anthonyfok
Copy link
Member Author

(Note to self: Next time, test before pushing a commit for the first time. 😉)

Finally got my PR to work as expected. My initial push erroneously used viper.GetBool("watch") which was never set and thus simply disabled watchConfig() indiscriminately... Oops!

I then discovered that the config watch only worked the first time when I do echo "" >> docs/config.toml, and then it got stuck, hence I added one more line to fix the problem. From the commit log:

Also, force DisableLiveReload to true when running "hugo --watch" (build-only non-server mode) to prevent livereload.ForceRefresh(), which would end up blocking watchConfig() forever, from being called because livereload.Initialize() is never called in this case.

This fixes the bug where "hugo --watch" could only reload config.toml once before it gets stuck for good at livereload.ForceRefresh().

This is also consistent with Hugo's existing behaviour: Non-server "hugo --watch" has never injected livereload.js since the inception of the "watch" feature in Hugo v0.12.

@spf13
Copy link
Contributor

spf13 commented Jan 29, 2016

This looks great. You've fixed two bugs in one commit. Merged as e8eb618

@spf13 spf13 closed this Jan 29, 2016
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants