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

Handle CHMOD only events in hugo server #4054

Open
BernCarney opened this issue Nov 4, 2017 · 9 comments
Open

Handle CHMOD only events in hugo server #4054

BernCarney opened this issue Nov 4, 2017 · 9 comments

Comments

@BernCarney
Copy link

Currently use a windows PC as my main machine with linux containers in docker as an, attempted, dev environment. Unfortunately with the lack of support for file change events between windows and linux, this has been a pain.

One work around that was promising was Docker-Windows-Volume-Watcher, but unfortunately, it doesn't work with the way Hugo Server handles file change events. Hugo server does not recognize chmod and touch events as file modifications (it sees them but ignores them) which the aforementioned tool uses as a workaround.

That is why I am proposing a flag that allows the hugo server to be run where chmod/touch events are not ignored (ie: hugo server --notify-all) until Windows or Docker comes up with a more permanent solution to the file sync issue between linux and windows.

I understand this is not a bug with Hugo but moreso with the underlying systems I am using which is why I have labeled it a feature request.

Issue for reference: Docker-Windows-Volume-Watcher Issue 4

@bep
Copy link
Member

bep commented Nov 4, 2017

I have spent some time debugging this myself on various OSes, and I can feel your pain.

  • In "normal cases" we see a mix of CHMOD, WRITE, CREATE, DELETE events.
  • Hugo currently throws away the CHMOD events.
  • If you say that your use case only triggers CHMOD, then we could apply some logic that said "if events contain only CHMOD", then update.
  • Note that we have some partial logic that differentiates between WRITE etc. This CHMOD situtation should be functionally same as a DELETE followed by a CREATE.

@bep bep changed the title [Feature Request] Flag to Make Hugo Server trigger on CHMOD/Touch events Hanlde CHMOD only events in hugo server Nov 4, 2017
@bep bep added the Enhancement label Nov 4, 2017
@bep bep added this to the v0.32 milestone Nov 4, 2017
@moorereason moorereason changed the title Hanlde CHMOD only events in hugo server Handle CHMOD only events in hugo server Nov 6, 2017
@bep bep modified the milestones: v0.32, v0.33 Dec 16, 2017
@bep bep modified the milestones: v0.33, v0.34 Jan 11, 2018
@bep bep modified the milestones: v0.34, v0.35, v0.36 Jan 22, 2018
@zimmski
Copy link

zimmski commented Jan 30, 2018

We are running into this problem. We decided to use Hugo for our new website and we are developing it inside a Vagrant VM. Alright, VirtualBox does not do events on synced-folders and we are using NFS so there is no chance of using inotify anyway. However, there are plugins such as https://github.com/adrienkohlbecker/vagrant-fsnotify that forward the events by executing commands inside the VM: "touch $file" and "touch $file && rm $file" in this case.

The problem is, Hugo does not do a rebuild on CHMOD. And I think it is because of this line https://github.com/gohugoio/hugo/blob/master/commands/hugo.go#L1087 (I am new to Hugo so please correct me if I am wrong). Would it be possible to simply add a flag to enable CHMOD again for users (like us) which have only the possibility of CHMOD events.

@bep
Copy link
Member

bep commented Jan 30, 2018

Would it be possible to simply add a flag to enable CHMOD again for users (like us) which have only the possibility of CHMOD events.

I not a big fan of "adding a flag" to solve any problem.

A patch for this has to be a little more involved: Let CHMOD trigger rebuild only if it is not accompanied by other event types, and add some kind of throttle to limit rebuilds.

@zimmski
Copy link

zimmski commented Jan 30, 2018

Your two requirements sound like a major undertaking for something that is documented in the source code as a MacOS problem. Furthermore, when I look through my today's log of events I do not see any case where I could reproduce that problem. So I cannot implement your requirements, since there would be no way for me to test them.

I do not see any compatibility promises, so the flag could be removed later if the infrastructure has been set up for your requirements. In any case: removing the workaround for MacOS with this flag would simply broaden Hugo's user-base.

@moorereason
Copy link
Contributor

@bep,
Can we make this OS X workaround of ignoring CHMOD events only applicable to OS X? It's not clear to me from the code comments if we ignore CHMOD solely because of OS X or if there's more to it than that.

if ev.Op&(fsnotify.Chmod|fsnotify.Write|fsnotify.Create) == fsnotify.Chmod && runtime.GOOS == "darwin" {
    continue
}

@bep
Copy link
Member

bep commented Jan 31, 2018

Can we make this OS X workaround of ignoring CHMOD events only applicable to OS X?

It is an application problem. Lots of software "touches files" (antivirus etc.). Creating a monkey patch now will maybe solve 1 person's problem, but break others.

@bep bep modified the milestones: v0.36, v0.37 Feb 3, 2018
@bep bep modified the milestones: v0.37, v0.38 Feb 11, 2018
@bep bep modified the milestones: v0.38, v0.39 Feb 21, 2018
@saitho
Copy link

saitho commented Mar 21, 2018

Creating a monkey patch now will maybe solve 1 person's problem, but break others.

Would it be possible to simply add a flag to enable CHMOD again for users (like us) which have only the possibility of CHMOD events.

I think a flag would be the best solution here... Wouldn't break existing installations as users would have to explicitly enable this feature. ;)

@bep bep added this to the v0.115.0 milestone Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants