Created
June 10, 2014 22:44
-
-
Save henvic/f7fe64d74df148962a88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Darwin has a low limit for file descriptors (256 per process) by default. | |
* | |
* Increase it for this process to avoid an EMFILE error when opening lots of | |
* files for releasing packages, compressing, etc. | |
* | |
* This is a temporary fix while node >= 0.12 isn't out as it is already fixed | |
* properly in the core. | |
* | |
* It uses the posix @ ~1.0.3 library found on the npm registry | |
* | |
* @param treeshold {Number} | |
* | |
* Reference: https://github.com/wearefractal/vinyl-fs/issues/14 | |
* | |
*/ | |
module.exports.increaseDarwinLowFileDescriptorsLimit = function fix(treeshold) { | |
var current, | |
posix; | |
if (process.platform === 'darwin') { | |
posix = require('posix'); | |
current = posix.getrlimit('nofile').soft; | |
if (current !== null && current < treeshold) { | |
posix.setrlimit('nofile', { | |
soft: treeshold, | |
hard: null | |
}); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment