jenius/roots — pull request #515 by joshrowley (2014-06-24 17:20:46+00:00)
Title: raise maximum number of open file descriptors to prevent EMFILE errors

Large roots project frequently fail to compile and raise the dreaded `Error: EMFILE, too many open files` error. This is due to the underlying OS setting a limit on the number of files any process can have open at simultaneously. On OSX, this number defaults to `256`, which is really low, especially since node modules tend to be a large number of very small files. Add in all the files we're watching and manipulating through roots and we hit this limit pretty quickly.

This raises the limit to a default of `10000` or a `ROOTS_RLIMIT` environment variable value. It persists through to the workers roots creates, and doesn't affect any other running processes.

I really don't know what the equivalent issue would be on a Windows machine, nor a good way to test this, but large sites like carrot.is do not compile without this fix. Also if someone can test that the `posix.setrlimit` call doesn't break on Windows that'd be great.