Visual Studio Code is unable to watch for file changes in this large workspace

2020-12-04 16:16:20

参考地址 1 Visual Studio Code on Linux

参考地址2  How Meteor watches your files for changes

解决办法   直接输入

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p


When you run your Meteor app in local development mode, the meteor command-line tool watches your source code for changes. (This page describes the behavior as of Meteor 1.0.2.1.)

There are two different strategies that meteor uses for change watching: efficient system-specific APIs like inotify (on Linux) and kqueue (on OSX), and a slower but more reliable "stat polling" method. inotify/kqueue is less reliable because it does not work on every system, and sometimes meteor can't even tell if it doesn't work. Stat polling is slower in two ways: it only looks for changes once every "polling interval", and the actual check that it does consumes more CPU.

By default, meteor uses both inotify/kqueue and stat polling, with a polling interval of 5 seconds; if it detects that inotify/kqueue isn't working, it uses a polling interval of 0.5 seconds.

This means that on most systems, changes are detected very quickly by inotify/kqueue. On systems where inotify/kqueue doesn't work, the stat polling fallback still works, but it does use more CPU than if inotify/kqueue works; and if meteor was unable to automatically detect that inotify/kqueue didn't work, you may have to wait up to 5 seconds for stat polling to notice file changes.

The rest of this wiki page describes two ways in which you can improve the performance of Meteor file watching.

  • There are some circumstances where inotify doesn't work (causing meteor to fall back to the CPU-hungry 0.5 second poll), but a simple configuration change will make inotify work.

  • There are some circumstances where inotify/kqueue doesn't work but meteor is unable to detect this, so only the high-latency 5 second poll happens. While you can't make inotify/kqueue work in this case, you can at least tell meteor to use a faster poll to detect changes sooner.

Making inotify work on Linux systems where it doesn't work

(Note: this section is Linux-specific: it will not work on OS X, and the warning message below should not be displayed there. If you do see this warning on OS X, please file a bug!)

Linux users may see a message saying:

=> It looks like a simple tweak to your system's configuration will make many
   tools (including this Meteor command) more efficient. To learn more, see
   https://github.com/meteor/meteor/wiki/File-Change-Watcher-Efficiency

This message means that meteor tried to use the Linux inotify API to watch for file changes, but you've already reached the system-wide limit for the number of files that you can watch (probably in a different program entirely!).

Fortunately, this is easy to fix. Just run this command at your shell, entering your password when prompted:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

(Alternatively, use another mechanism to edit /etc/sysctl.conf as root and add the line fs.inotify.max_user_watches=524288 to the bottom, then run sudo sysctl -p.)

After running these commands, you should no longer see the "simple tweak" message when running meteor. (If you still do, file a bug!) Meteor is now using the efficient inotify API

If you do not have superuser access on your computer, you won't be able to run these commands. In that case, you may set the METEOR_WATCH_FORCE_POLLING environment variable as described in the next section, which will hide the warning and not try to use inotify at all.

Running meteor on a network/shared filesystem

Some filesystems don't support inotify/kqueue at all, but also don't allow meteor to detect this error case. In this situation, meteor will still detect file changes with the stat poller at the 5 second polling interval, but you may want to poll more often in order to detect changes faster.

The most common filesystems with this issue are network or shared filesystems like NFS or VirtualBox shared folders (vboxsf). For example, if you are using Vagrant or a similar tool to run meteor inside a virtual machine, and you are sharing your app source directory between your host machine and the VM, inotify may be unable to detect changes made on your host machine. The symptom will be that meteor doesn't even start trying to rebuild your app until up to 5 seconds after you make the change.

To improve this situation, on the machine where you are running meteor (eg, inside your VM), set the METEOR_WATCH_FORCE_POLLING environment variable to any non-empty value. For example, put the line METEOR_WATCH_FORCE_POLLING=true into the .bashrc file in your home directory.

If you would like finer control over the polling interval (to put it somewhere between the options of 5 seconds and 500 ms), set the METEOR_WATCH_POLLING_INTERVAL_MS environment variable to a number.


  • 2020-12-17 10:57:34

    使用 MediaSource 搭建流式播放器

    Media Source Extensions(媒体源扩展)大大地扩展了浏览器的媒体播放功能,提供允许JavaScript 生成媒体流。这可以用于自适应流(adaptive streaming,也是我毕设的研究方向)及随时间变化的视频直播流(live streaming)等应用场景。

  • 2020-12-17 11:00:37

    H5流式播放(FMP4转封装与mediaSource)

    W3C上有明确关于mediaSource 扩展接口的文档。mediaSource 扩展文档中是这么定义的, 它允许JS脚本动态构建媒体流用于和,允许JS传送媒体块到H5媒体元素。这种接口的应用可以让h5播放器实现持续添加数据进行播放。做as的朋友都知道as中的appendBytes方法,一种添加二进制数据进行播放的方式。这两种接口在概念上是类似的。只是里面的定义和对媒体文件的要求有所不同。对于mediaSource扩展接口我只介绍我们主要应用的几个。

  • 2020-12-18 17:15:29

    coTurn stun服务器搭建,禁用turn

    https://github.com/coturn/coturn 在这里git clone 下来然后编译安装,一切默认即可。编译后,也可以不用安装。在编译目录下bin文件夹下有turnserver turnutils_stunclient turnutils_uclient 这三个等一下会用到的软件。

  • 2020-12-18 17:26:25

    coturn配置文件详细解释

    Coturn 是webrtc,p2p视频通话必不少的,主要包含2个主要功能stun服务, turn服务 Coturn 的githup地址为 https://github.com/coturn/coturn/

  • 2020-12-21 06:26:16

    为UIView添加点击事件

    最近经常碰到要将UIImageView和UILabel看成整体的情况,我于是就将他俩用UIView包起来,那么怎么给一个UIView添加点击事件,可以这么实现: