diff --git a/README.md b/README.md index be18682..4ab4ecc 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,12 @@ The `up` command accepts the following options: - Whether to watch for changes. - Watches the working directory for changes. +- `-i`/`--ignore` `` + + - When using `--watch`, define paths to ignore (comma separated) + - `.git,node_modules` are ignored by default and are added to your ignored paths + - eg: `--ignore public,vendor` + - `-r`/`--require` `` - Specifies a module to require from each worker. diff --git a/bin/up b/bin/up index 9bf8925..9dee198 100755 --- a/bin/up +++ b/bin/up @@ -39,6 +39,7 @@ program .option('-T, --title ', 'Process title.', 'up') .option('-f, --pidfile <pidfile>', 'Write port to pidfile') .option('-w, --watch', 'Watch the module directory for changes.') + .option('-i, --ignore <paths>', 'Ignore files when watching for changes.') .option('-r, --require <file>', 'Module to require from each worker.') .option('-n, --number <workers>', 'Number of workers to spawn.' , 'development' == process.env.NODE_ENV ? 1 : cpus) @@ -226,7 +227,11 @@ if (undefined != program.watch) { * Ignored directories. */ - var ignore = ['node_modules', '.git']; + if (undefined != program.ignore) { + var ignore = ['node_modules', '.git'].concat(program.ignore.split(",")); + } else { + var ignore = ['node_modules', '.git']; + } /** * Ignored files. diff --git a/lib/up.js b/lib/up.js index 72ab44c..ae5ac2b 100644 --- a/lib/up.js +++ b/lib/up.js @@ -1,4 +1,3 @@ - /** * Module dependencies. */ @@ -257,6 +256,18 @@ UpServer.prototype.defaultWS = function (req, res, next) { if(this.workers.length && matcher && matcher.length > 2) { // transport = matcher[1], sid = matcher[2] var sid = matcher[2]; + + if(typeof(sid) !== 'number') { + var glyphs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + var result = 0; + + sid = sid.split(''); + for(var index = sid.length - 1; index >= 0; index--) { + result = (result * 64) + glyphs.indexOf(sid[index]); + } + sid = result; + } + var workerIndex = sid % this.workers.length; next(this.workers[workerIndex].port); } else if (this.workers.length) {