From 0a8e76d8174df129a8cfebfe3625d1bd8ac5a0f9 Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet Date: Wed, 26 Sep 2012 11:44:41 -0400 Subject: [PATCH 1/6] Added --ignore CLI option to ignore some paths when watching for changes --- bin/up | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/up b/bin/up index 9bf8925..76219b3 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,14 @@ if (undefined != program.watch) { * Ignored directories. */ - var ignore = ['node_modules', '.git']; + if (undefined != program.ignore) { + console.log(program.ignore); + var ignore = program.ignore.split(","); + ignore = ['node_modules', '.git'].concat(ignore); + console.log(ignore); + } else { + var ignore = ['node_modules', '.git']; + } /** * Ignored files. From c050ff8198ed5fc6678871e8046cbc6e103a9966 Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet <jeromegn@gmail.com> Date: Wed, 26 Sep 2012 11:48:20 -0400 Subject: [PATCH 2/6] Cleaning up. Removed some console.logs --- bin/up | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/up b/bin/up index 76219b3..41878e8 100755 --- a/bin/up +++ b/bin/up @@ -228,10 +228,8 @@ if (undefined != program.watch) { */ if (undefined != program.ignore) { - console.log(program.ignore); var ignore = program.ignore.split(","); ignore = ['node_modules', '.git'].concat(ignore); - console.log(ignore); } else { var ignore = ['node_modules', '.git']; } From dd58d63d5835e3b46e21cc937ef9ef0781d0aa6d Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet <jeromegn@gmail.com> Date: Wed, 26 Sep 2012 12:00:30 -0400 Subject: [PATCH 3/6] Added documentation for new --ignore option --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) 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` `<paths>` + + - 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` `<mod>` - Specifies a module to require from each worker. From facccad508ac21c575ff3213abb76c23fbc8a0b4 Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet <jeromegn@gmail.com> Date: Wed, 26 Sep 2012 12:08:31 -0400 Subject: [PATCH 4/6] Simplified. --- bin/up | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/up b/bin/up index 41878e8..9dee198 100755 --- a/bin/up +++ b/bin/up @@ -228,8 +228,7 @@ if (undefined != program.watch) { */ if (undefined != program.ignore) { - var ignore = program.ignore.split(","); - ignore = ['node_modules', '.git'].concat(ignore); + var ignore = ['node_modules', '.git'].concat(program.ignore.split(",")); } else { var ignore = ['node_modules', '.git']; } From 4ba1ee1294065f0e1c7f66c08420b1c10fe32a8a Mon Sep 17 00:00:00 2001 From: Rakshit Menpara <deltasquare4@gmail.com> Date: Tue, 2 Oct 2012 13:31:31 +0530 Subject: [PATCH 5/6] Fix for a crash when socketId is base64 * workerIndex is NaN when socketIds are base64 (Socket.io > 0.9.6) * Fix it by converting socketId to a number --- lib/up.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/up.js b/lib/up.js index 72ab44c..faca2c6 100644 --- a/lib/up.js +++ b/lib/up.js @@ -257,6 +257,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 in glyphs) { + result = (result * 64) + glyphs.indexOf(glyphs[index]); + } + sid = result; + } + var workerIndex = sid % this.workers.length; next(this.workers[workerIndex].port); } else if (this.workers.length) { From cac792616f9392ff929fc8f39dc208ece9423c13 Mon Sep 17 00:00:00 2001 From: Rakshit Menpara <deltasquare4@gmail.com> Date: Wed, 3 Oct 2012 12:24:12 +0530 Subject: [PATCH 6/6] Fixed wrong sid to number calculation --- lib/up.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/up.js b/lib/up.js index faca2c6..ae5ac2b 100644 --- a/lib/up.js +++ b/lib/up.js @@ -1,4 +1,3 @@ - /** * Module dependencies. */ @@ -263,8 +262,8 @@ UpServer.prototype.defaultWS = function (req, res, next) { var result = 0; sid = sid.split(''); - for(var index in glyphs) { - result = (result * 64) + glyphs.indexOf(glyphs[index]); + for(var index = sid.length - 1; index >= 0; index--) { + result = (result * 64) + glyphs.indexOf(sid[index]); } sid = result; }