Created
February 26, 2014 02:02
-
-
Save andrewrk/9221986 to your computer and use it in GitHub Desktop.
ENOSPC troubleshooting
This file contains 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
var fs = require('fs'); | |
var crypto = require('crypto'); | |
var path = require('path'); | |
var mkdirp = require('mkdirp'); | |
var count = 2863 * 8; | |
var dirs = [n()]; | |
while (count > 0) { | |
if (Math.random() < 0.66) { | |
var index = Math.floor(Math.random() * dirs.length); | |
dirs[index] = path.join(dirs[index], n()); | |
} else { | |
dirs.push(n()); | |
} | |
count -= 1; | |
} | |
console.log("making directories..."); | |
dirs.forEach(function(dir) { | |
mkdirp(path.join("lots-of-dirs", dir), noop); | |
}); | |
function n() { | |
return crypto.pseudoRandomBytes(4).toString('hex'); | |
} | |
function noop() {} |
This file contains 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
var fs = require('fs'); | |
var findit = require('findit'); | |
var walker = findit('lots-of-dirs'); | |
var count = 0; | |
walker.on('directory', function(filename) { | |
try { | |
fs.watch(filename, {persistent: true}, onChange); | |
count += 1; | |
} catch (err) { | |
if (err.code === 'ENOSPC') { | |
console.log("caught ENOSPC", count); | |
} | |
} | |
}); | |
function onChange(event, filename) { | |
console.log("event", event, "filename", filename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment