migrating repo to Bodyrep org

This commit is contained in:
2013-01-19 11:23:43 -05:00
parent 31b7303f43
commit 4ea082330b
891 changed files with 142706 additions and 0 deletions

96
node_modules/supervisor/README.md generated vendored Normal file
View File

@@ -0,0 +1,96 @@
# node-supervisor
A little supervisor script for nodejs. It runs your program, and
watches for code changes, so you can have hot-code reloading-ish
behavior, without worrying about memory leaks and making sure you
clean up all the inter-module references, and without a whole new
`require` system.
## node-supervisor -?
Node Supervisor is used to restart programs when they crash.
It can also be used to restart programs when a *.js file changes.
Usage:
supervisor [options] <program>
supervisor [options] -- <program> [args ...]
Required:
<program>
The program to run.
Options:
-w|--watch <watchItems>
A comma-delimited list of folders or js files to watch for changes.
When a change to a js file occurs, reload the program
Default is '.'
-e|--extensions <extensions>
Specific file extensions to watch in addition to defaults.
Used when --watch option includes folders
Default is 'node|js'
-x|--exec <executable>
The executable that runs the specified program.
Default is 'node'
--debug
Start node with --debug flag.
--debug-brk
Start node with --debug-brk flag.
-n|--no-restart-on error|exit
Don't automatically restart the supervised program if it ends.
Supervisor will wait for a change in the source files.
If "error", an exit code of 0 will still restart.
If "exit", no restart regardless of exit code.
-h|--help|-?
Display these usage instructions.
-q|--quiet
Suppress DEBUG messages
Examples:
supervisor myapp.js
supervisor myapp.coffee
supervisor -w scripts -e myext -x myrunner myapp
supervisor -w lib,server.js,config.js server.js
supervisor -- server.js -h host -p port
## Simple Install
Install npm, and then do this:
npm install supervisor -g
You don't even need to download or fork this repo at all.
## Fancy Install
Get this code, install npm, and then do this:
npm link
## todo
1. Re-attach to a process by pid. If the supervisor is
backgrounded, and then disowned, the child will keep running. At
that point, the supervisor may be killed, but the child will keep
on running. It'd be nice to have two supervisors that kept each
other up, and could also perhaps run a child program.
2. Run more types of programs than just "node blargh.js".
3. Be able to run more than one program, so that you can have two
supervisors supervise each other, and then also keep some child
server up.
4. When watching, it'd be good to perhaps bring up a new child
and then kill the old one gently, rather than just crashing the
child abruptly.
5. Keep the pid in a safe place, so another supervisor can pull
it out if told to supervise the same program.
6. It'd be pretty cool if this program could be run just like
doing `node blah.js`, but could somehow "know" which files had
been loaded, and restart whenever a touched file changes.

20
node_modules/supervisor/debug.patch generated vendored Normal file
View File

@@ -0,0 +1,20 @@
diff --git a/lib/supervisor.js b/lib/supervisor.js
index ae69a2d..6c2c795 100644
--- a/lib/supervisor.js
+++ b/lib/supervisor.js
@@ -187,6 +187,7 @@ function startProgram (prog, exec) {
util.debug("Starting child process with '" + exec + " " + prog.join(" ") + "'");
crash_queued = false;
var child = exports.child = spawn(exec, prog);
+ util.debug("Spawned child process: " + child.pid);
child.stdout.addListener("data", function (chunk) { chunk && util.print(chunk); });
child.stderr.addListener("data", function (chunk) { chunk && util.debug(chunk); });
child.addListener("exit", function (code) {
@@ -210,6 +211,7 @@ function crash () {
setTimeout(function() {
if (child) {
util.debug("crashing child");
+ util.debug("Crashing child process: " + child.pid);
process.kill(child.pid);
} else {
util.debug("restarting child");

13
node_modules/supervisor/lib/cli-wrapper.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env node
var path = require("path")
, args = process.argv.slice(1)
var arg, base;
do arg = args.shift();
while ( arg !== __filename
&& (base = path.basename(arg)) !== "node-supervisor"
&& base !== "supervisor"
&& base !== "supervisor.js"
)
require("./supervisor").run(args)

301
node_modules/supervisor/lib/supervisor.js generated vendored Normal file
View File

@@ -0,0 +1,301 @@
var util = require("util");
var fs = require("fs");
var spawn = require("child_process").spawn;
var path = require("path");
var fileExtensionPattern;
var startChildProcess;
var noRestartOn = null;
var debug = true;
var verbose = false;
var ignoredPaths = {};
exports.run = run;
function run (args) {
var arg, next, watch, ignore, program, extensions, executor, poll_interval, debugFlag, debugBrkFlag;
while (arg = args.shift()) {
if (arg === "--help" || arg === "-h" || arg === "-?") {
return help();
} else if (arg === "--quiet" || arg === "-q") {
debug = false;
util.debug = function(){};
util.puts = function(){};
} else if (arg === "--verbose" || arg === "-V") {
verbose = true;
} else if (arg === "--watch" || arg === "-w") {
watch = args.shift();
} else if (arg === "--ignore" || arg === "-i") {
ignore = args.shift();
} else if (arg === "--poll-interval" || arg === "-p") {
poll_interval = parseInt(args.shift());
} else if (arg === "--extensions" || arg === "-e") {
extensions = args.shift();
} else if (arg === "--exec" || arg === "-x") {
executor = args.shift();
} else if (arg === "--no-restart-on" || arg === "-n") {
noRestartOn = args.shift();
} else if (arg === "--debug") {
debugFlag = true;
} else if (arg === "--debug-brk") {
debugBrkFlag = true;
} else if (arg === "--") {
program = args;
break;
} else if (arg.indexOf("-") && !args.length) {
// Assume last arg is the program
program = [arg];
}
}
if (!program) {
return help();
}
if (!watch) {
watch = ".";
}
if (!poll_interval) {
poll_interval = 100;
}
var programExt = program.join(" ").match(/.*\.(\S*)/);
programExt = programExt && programExt[1];
if (!extensions) {
// If no extensions passed try to guess from the program
extensions = "node|js";
if (programExt && extensions.indexOf(programExt) == -1)
extensions += "|" + programExt;
}
extensions = extensions.replace(/,/g, "|");
fileExtensionPattern = new RegExp("^.*\.(" + extensions + ")$");
if (!executor) {
executor = (programExt === "coffee") ? "coffee" : "node";
}
if (debugFlag) {
program.unshift("--debug");
}
if (debugBrkFlag) {
program.unshift("--debug-brk");
}
try {
// Pass kill signals through to child
[ "SIGTERM", "SIGINT", "SIGHUP", "SIGQUIT" ].forEach( function(signal) {
process.on(signal, function () {
var child = exports.child;
if (child) {
util.debug("Sending "+signal+" to child...");
child.kill(signal);
}
process.exit();
});
});
} catch(e) {
// Windows doesn't support signals yet, so they simply don't get this handling.
// https://github.com/joyent/node/issues/1553
}
util.puts("")
util.debug("Running node-supervisor with");
util.debug(" program '" + program.join(" ") + "'");
util.debug(" --watch '" + watch + "'");
util.debug(" --ignore '" + ignore + "'");
util.debug(" --extensions '" + extensions + "'");
util.debug(" --exec '" + executor + "'");
util.puts("");
// store the call to startProgramm in startChildProcess
// in order to call it later
startChildProcess = function() { startProgram(program, executor); };
// if we have a program, then run it, and restart when it crashes.
// if we have a watch folder, then watch the folder for changes and restart the prog
startChildProcess();
if (ignore) {
var ignoreItems = ignore.split(',');
ignoreItems.forEach(function (ignoreItem) {
ignoreItem = path.resolve(ignoreItem);
ignoredPaths[ignoreItem] = true;
util.debug("Ignoring directory '" + ignoreItem + "'.");
});
}
var watchItems = watch.split(',');
watchItems.forEach(function (watchItem) {
watchItem = path.resolve(watchItem);
util.debug("Watching directory '" + watchItem + "' for changes.");
findAllWatchFiles(watchItem, function(f) {
watchGivenFile( f, poll_interval );
});
});
};
function print (m, n) { util.print(m+(!n?"\n":"")); return print; }
function help () {
print
("")
("Node Supervisor is used to restart programs when they crash.")
("It can also be used to restart programs when a *.js file changes.")
("")
("Usage:")
(" supervisor [options] <program>")
(" supervisor [options] -- <program> [args ...]")
("")
("Required:")
(" <program>")
(" The program to run.")
("")
("Options:")
(" -w|--watch <watchItems>")
(" A comma-delimited list of folders or js files to watch for changes.")
(" When a change to a js file occurs, reload the program")
(" Default is '.'")
("")
(" -i|--ignore <ignoreItems>")
(" A comma-delimited list of folders to ignore for changes.")
(" No default")
("")
(" -p|--poll-interval <milliseconds>")
(" How often to poll watched files for changes.")
(" Defaults to Node default.")
("")
(" -e|--extensions <extensions>")
(" Specific file extensions to watch in addition to defaults.")
(" Used when --watch option includes folders")
(" Default is 'node|js'")
("")
(" -x|--exec <executable>")
(" The executable that runs the specified program.")
(" Default is 'node'")
("")
(" --debug")
(" Start node with --debug flag.")
("")
(" --debug-brk")
(" Start node with --debug-brk flag.")
("")
(" -n|--no-restart-on error|exit")
(" Don't automatically restart the supervised program if it ends.")
(" Supervisor will wait for a change in the source files.")
(" If \"error\", an exit code of 0 will still restart.")
(" If \"exit\", no restart regardless of exit code.")
("")
(" -h|--help|-?")
(" Display these usage instructions.")
("")
(" -q|--quiet")
(" Suppress DEBUG messages")
("")
(" -V|--verbose")
(" Show extra DEBUG messages")
("")
("Examples:")
(" supervisor myapp.js")
(" supervisor myapp.coffee")
(" supervisor -w scripts -e myext -x myrunner myapp")
(" supervisor -- server.js -h host -p port")
("");
};
function startProgram (prog, exec) {
util.debug("Starting child process with '" + exec + " " + prog.join(" ") + "'");
crash_queued = false;
var child = exports.child = spawn(exec, prog, {stdio: 'inherit'});
if (child.stdout) {
// node < 0.8 doesn't understand the 'inherit' option, so pass through manually
child.stdout.addListener("data", function (chunk) { chunk && util.print(chunk); });
child.stderr.addListener("data", function (chunk) { chunk && util.debug(chunk); });
}
child.addListener("exit", function (code) {
if (!crash_queued) {
util.debug("Program " + exec + " " + prog.join(" ") + " exited with code " + code + "\n");
exports.child = null;
if (noRestartOn == "exit" || noRestartOn == "error" && code !== 0) return;
}
startProgram(prog, exec);
});
}
var timer = null, mtime = null; crash_queued = false;
function crash () {
if (crash_queued)
return;
crash_queued = true;
var child = exports.child;
setTimeout(function() {
if (child) {
util.debug("crashing child");
process.kill(child.pid);
} else {
util.debug("restarting child");
startChildProcess();
}
}, 50);
}
function crashWin (event, filename) {
var shouldCrash = true;
if( event === 'change' ) {
if (filename) {
filename = path.resolve(filename);
Object.keys(ignoredPaths).forEach(function (ignorePath) {
if ( filename.indexOf(ignorePath + '\\') === 0 ) {
shouldCrash = false;
}
});
}
if (shouldCrash)
crash();
}
}
function crashOther (oldStat, newStat) {
// we only care about modification time, not access time.
if ( newStat.mtime.getTime() !== oldStat.mtime.getTime() )
crash();
}
var nodeVersion = process.version.split(".");
var isWindowsWithoutWatchFile = process.platform === 'win32' && parseInt(nodeVersion[1]) <= 6;
function watchGivenFile (watch, poll_interval) {
if (isWindowsWithoutWatchFile)
fs.watch(watch, { persistent: true, interval: poll_interval }, crashWin);
else
fs.watchFile(watch, { persistent: true, interval: poll_interval }, crashOther);
if (verbose)
util.debug("watching file '" + watch + "'");
}
var findAllWatchFiles = function(dir, callback) {
dir = path.resolve(dir);
if (ignoredPaths[dir])
return;
fs.stat(dir, function(err, stats){
if (err) {
util.error('Error retrieving stats for file: ' + dir);
} else {
if (stats.isDirectory()) {
if (isWindowsWithoutWatchFile) callback(dir);
fs.readdir(dir, function(err, fileNames) {
if(err) {
util.error('Error reading path: ' + dir);
}
else {
fileNames.forEach(function (fileName) {
findAllWatchFiles(path.join(dir, fileName), callback);
});
}
});
} else {
if (!isWindowsWithoutWatchFile && dir.match(fileExtensionPattern)) {
callback(dir);
}
}
}
});
};

233
node_modules/supervisor/lib/supervisor.js.orig generated vendored Normal file
View File

@@ -0,0 +1,233 @@
<<<<<<< HEAD
var util = require("util");
=======
var sys = require("sys");
>>>>>>> coreyjewett/master
var fs = require("fs");
var spawn = require("child_process").spawn;
var fileExtensionPattern;
exports.run = run;
function run (args) {
<<<<<<< HEAD
var arg, next, watch, program, extensions, executor, poll_interval;
=======
var arg, next, watch, program, programArgs, extensions, executor;
>>>>>>> coreyjewett/master
while (arg = args.shift()) {
if (arg === "--help" || arg === "-h" || arg === "-?") {
return help();
} else if (arg === "--watch" || arg === "-w") {
watch = args.shift();
} else if (arg === "--poll-interval" || arg === "-p") {
poll_interval = parseInt(args.shift());
} else if (arg === "--extensions" || arg === "-e") {
extensions = args.shift();
} else if (arg === "--exec" || arg === "-x") {
executor = args.shift();
} else if (arg === "--") {
// Remaining args are: program [args, ...]
program = args.shift();
programArgs = args.slice(0);
break;
} else if (arg.indexOf("-") && !args.length) {
// Assume last arg is the program
program = arg;
}
}
if (!program) {
return help();
}
if (!watch) {
watch = ".";
}
if (!poll_interval) {
poll_interval = 0;
}
var programExt = program.match(/.*\.(.*)/);
programExt = programExt && programExt[1];
if (!extensions) {
// If no extensions passed try to guess from the program
extensions = "node|js";
if (programExt && extensions.indexOf(programExt) == -1)
extensions += "|" + programExt;
}
<<<<<<< HEAD
fileExtensionPattern = new RegExp("^.*\.(" + extensions + ")$");
if (!executor) {
executor = (programExt === "coffee") ? "coffee" : "node";
}
util.puts("")
util.debug("Running node-supervisor with");
util.debug(" program '" + program + "'");
util.debug(" --watch '" + watch + "'");
util.debug(" --extensions '" + extensions + "'");
util.debug(" --exec '" + executor + "'");
util.puts("")
=======
fileExtensionPattern = new RegExp(".*\.(" + extensions + ")");
if (!executor) {
executor = (programExt === "coffee") ? "coffee" : "node";
}
sys.puts("");
sys.debug("Running node-supervisor with");
sys.debug(" program '" + program + "'");
sys.debug(" --watch '" + watch + "'");
sys.debug(" --extensions '" + extensions + "'");
sys.debug(" --exec '" + executor + "'");
sys.puts("");
>>>>>>> coreyjewett/master
// if we have a program, then run it, and restart when it crashes.
// if we have a watch folder, then watch the folder for changes and restart the prog
startProgram(program, executor, programArgs);
var watchItems = watch.split(',');
watchItems.forEach(function (watchItem) {
if (!watchItem.match(/^\/.*/)) { // watch is not an absolute path
// convert watch item to absolute path
watchItem = process.cwd() + '/' + watchItem;
}
util.debug("Watching directory '" + watchItem + "' for changes.");
findAllWatchFiles(watchItem, function(f) {
watchGivenFile( f, poll_interval );
});
});
};
<<<<<<< HEAD
function print (m, n) { util.print(m+(!n?"\n":"")); return print }
=======
function print (m, n) { sys.print(m+(!n?"\n":"")); return print; }
>>>>>>> coreyjewett/master
function help () {
print
("")
("Node Supervisor is used to restart programs when they crash.")
("It can also be used to restart programs when a *.js file changes.")
("")
("Usage:")
(" supervisor [options] <program>")
("")
("Required:")
(" <program>")
(" The program to run.")
("")
("Options:")
(" -w|--watch <watchItems>")
(" A comma-delimited list of folders or js files to watch for changes.")
(" When a change to a js file occurs, reload the program")
(" Default is '.'")
("")
(" -p|--poll-interval <milliseconds>")
(" How often to poll watched files for changes.")
(" Defaults to Node default.")
("")
(" -e|--extensions <extensions>")
(" Specific file extensions to watch in addition to defaults.")
(" Used when --watch option includes folders")
(" Default is 'node|js'")
("")
(" -x|--exec <executable>")
(" The executable that runs the specified program.")
(" Default is 'node'")
("")
(" -h|--help|-?")
(" Display these usage instructions.")
("")
("Examples:")
(" supervisor myapp.js")
(" supervisor myapp.coffee")
(" supervisor -w scripts -e myext -x myrunner myapp")
("");
};
<<<<<<< HEAD
function startProgram (prog, exec) {
util.debug("Starting child process with '" + exec + " " + prog + "'");
var child = exports.child = spawn(exec, [prog]);
child.stdout.addListener("data", function (chunk) { chunk && util.print(chunk) });
child.stderr.addListener("data", function (chunk) { chunk && util.debug(chunk) });
child.addListener("exit", function () { startProgram(prog, exec) });
=======
function startProgram (prog, exec, args) {
if (args)
sys.debug("Starting child process with '" + exec + " " + prog + " " + args + "'");
else
sys.debug("Starting child process with '" + exec + " " + prog + "'");
var spawnme = args ? [prog].concat(args) : [prog];
var child = exports.child = spawn(exec, spawnme);
child.stdout.addListener("data", function (chunk) { chunk && sys.print(chunk); });
child.stderr.addListener("data", function (chunk) { chunk && sys.debug(chunk); });
child.addListener("exit", function () { startProgram(prog, exec, args); });
>>>>>>> coreyjewett/master
}
var timer = null, mtime = null; crash_queued = false;
function crash (oldStat, newStat) {
// we only care about modification time, not access time.
if (
newStat.mtime.getTime() === oldStat.mtime.getTime()
|| crash_queued
) return;
<<<<<<< HEAD
crash_queued = true;
=======
if (counter === -1) {
timer = setTimeout(stopCrashing, 1000);
}
counter ++;
>>>>>>> coreyjewett/master
var child = exports.child;
setTimeout(function() {
util.debug("crashing child");
process.kill(child.pid);
crash_queued = false;
}, 50);
}
<<<<<<< HEAD
function watchGivenFile (watch, poll_interval) {
fs.watchFile(watch, { persistent: true, interval: poll_interval }, crash);
=======
function watchGivenFile (watch) {
fs.watchFile(watch, { persistent: true, interval: 250 }, crash);
>>>>>>> coreyjewett/master
}
var findAllWatchFiles = function(path, callback) {
fs.stat(path, function(err, stats){
if (err) {
util.error('Error retrieving stats for file: ' + path);
} else {
if (stats.isDirectory()) {
fs.readdir(path, function(err, fileNames) {
if(err) {
util.puts('Error reading path: ' + path);
}
else {
fileNames.forEach(function (fileName) {
findAllWatchFiles(path + '/' + fileName, callback);
});
}
});
} else {
if (path.match(fileExtensionPattern)) {
callback(path);
}
}
}
});
};

104
node_modules/supervisor/package.json generated vendored Normal file
View File

@@ -0,0 +1,104 @@
{
"name": "supervisor",
"version": "0.5.0",
"description": "A supervisor program for running nodejs programs",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me"
},
"contributors": [
{
"name": "Todd Branchflower",
"email": "toddbran@stanford.edu"
},
{
"name": "Giannis Dzegoutanis",
"email": "erasmospunk@gmail.com"
},
{
"name": "Brian Ehmann",
"email": "behmann@gmail.com"
},
{
"name": "Corey Jewett",
"email": "cj@syntheticplayground.com"
},
{
"name": "Taka Kojima",
"email": "taka.kojima@ff0000.com"
},
{
"name": "Aneil Mallavarapu",
"email": "aneil@blipboard.com"
},
{
"name": "Jonathan 'Wolf' Rentzsch",
"email": "jwr.git@redshed.net"
},
{
"name": "Scott Sanders",
"email": "scott@stonecobra.com"
},
{
"name": "Fernando H. Silva",
"email": "ferhensil@gmail.com"
},
{
"name": "Kei Son",
"email": "heyacct@gmail.com"
},
{
"name": "David Taylor",
"email": "david@zensatellite.com"
},
{
"name": "Antonio Touriño",
"email": "atourino@gmail.com"
},
{
"name": "Oliver Wong",
"email": "oliver@owiber.com"
},
{
"name": "Ian Young",
"email": "ian.greenleaf@gmail.com"
},
{
"name": "jazzzz",
"email": "jazzzz@gmail.com"
},
{
"name": "rma4ok",
"email": "rma4ok@gmail.com"
}
],
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-supervisor.git"
},
"bugs": {
"name": "https://github.com/isaacs/node-supervisor/issues"
},
"homepage": "https://github.com/isaacs/node-supervisor/",
"main": "lib/supervisor.js",
"bin": {
"node-supervisor": "lib/cli-wrapper.js",
"supervisor": "lib/cli-wrapper.js"
},
"engines": {
"node": ">=0.3.7"
},
"preferGlobal": true,
"_id": "supervisor@0.5.0",
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.21",
"_nodeVersion": "v0.6.18",
"_defaultsLoaded": true,
"dist": {
"shasum": "750a796b2627a0562ae7d837cd6a250e23b6cb5a"
},
"_from": "supervisor"
}

25
node_modules/supervisor/package.json.orig generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{ "name" : "supervisor"
<<<<<<< HEAD
, "version" : "0.1.3"
=======
, "version" : "0.1.2cj"
>>>>>>> coreyjewett/master
, "description" : "A supervisor program for running nodejs programs"
, "author" : "Isaac Z. Schlueter <i@izs.me>"
, "contributors" : [ "Brian Ehmann <behmann@gmail.com>"
, "David Taylor <david@zensatellite.com>"
<<<<<<< HEAD
, "Antonio Touriño <atourino@gmail.com>"
, "Ian Young <ian.greenleaf@gmail.com>"
=======
, "Corey Jewett <cj@syntheticplayground.com>"
>>>>>>> coreyjewett/master
]
, "main" : "lib/supervisor.js"
, "bin" :
{ "node-supervisor" : "lib/cli-wrapper.js"
, "supervisor" : "lib/cli-wrapper.js"
}
, "engines" : { "node" : "~0.3.7 || 0.4 || 0.5 || 0.6" }
, "preferGlobal" : true
}