5HT / fs

📁 FS: Windows, Linux, Mac Driver
https://fs.n2o.dev
Other
234 stars 69 forks source link

directory that application is started in is always watched regardless of the path passed into start_link #29

Closed retrogradeorbit closed 7 years ago

retrogradeorbit commented 7 years ago

When I fs:start_link(fs_watcher, "/path/to/my/dir"), the inotify command is set up to watch that path "/path/to/my/dir", but also the current working directory the application was started in is also watched. This leads to the application crashing if the user starts it in a directory too close to root, with too many child directories, as it causes too many paths to be watched and that exceeds the value set in /proc/sys/fs/inotify/max_user_watches.

A classic example of this is if the application is setup as a system process under something like upstart. Here, the cwd is usually the root path "/", and then the application crashes with:

Failed to watch /; upper limit on inotify watches reached!
Please increase the amount of inotify watches allowed per user via `/proc/sys/fs/inotify/max_user_watches'.
proger commented 7 years ago

This was introduced in #18, ping @5HT @liveforeverx

proger commented 7 years ago

It looks like you can try mitigating this by setting backwards_compatible to false: https://github.com/synrc/fs/blob/master/src/fs_app.erl

@5HT any reason to keep backwards compatibility?

5HT commented 7 years ago

for me no, maybe we should ask Elixir developers

liveforeverx commented 7 years ago

@retrogradeorbit : Set backwards_compatible to false to disable this behaviour (as @proger suggests).