Grunt watch仅在使用Vagrant和NFS的5秒钟后检测到文件更改 [英] Grunt watch detects file changes only after 5 seconds with Vagrant and NFS
问题描述
Grunt手表(grunt-contrib-watch)用于触发浏览器中Web应用程序的重新加载.但是,在使用NFS同步文件夹的Vagrant虚拟机中运行文件时,注意到文件更改的速度很慢.更改文件只会在大约5秒钟后触发重新加载,尽管它有望几乎立即发生.为什么咕unt的手表这么慢才能发现变化?有什么方法可以使其更快?
Grunt watch (grunt-contrib-watch) is used to trigger reload of web app in browser. However, it is slow to notice file changes when running in a Vagrant virtual machine using NFS for synced folders. Changing a file triggers a reload only after about 5 seconds although it is expected to happen almost instantly. Why is grunt watch so slow to detect changes? Is there any way to make it faster?
借助VirtualBox同步的文件夹,grunt watch几乎可以立即检测到文件更改.但是,由于VirtualBox同步的文件夹在对大量文件执行某些其他操作时速度过慢,因此,在这种情况下,不能选择恢复到该状态.
With VirtualBox synced folders grunt watch detects file changes almost instantly. However, as VirtualBox synced folders are unacceptably slow for certain other operations on large amounts of files it is unfortunately not an option to revert back to it in this case.
推荐答案
在Vagrantfile
中尝试以下安装选项:
Try these mount options in your Vagrantfile
:
type: "nfs", mount_options: ['actimeo=1']
这将大大减少NFS文件属性缓存超时.我遇到了类似的麻烦,在等待gulp和Django服务器重新加载时,看到Vagrant/NFS出现大量延迟.这样就解决了;现在可以立即检测到文件更改.
This will greatly reduce the NFS file attribute caching timeout. I was having similar troubles, seeing large delays with Vagrant/NFS when waiting for gulp and Django server reloads. This fixed it; file changes are now detected instantly.
这篇关于Grunt watch仅在使用Vagrant和NFS的5秒钟后检测到文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!