1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 02:42:48 +00:00

Added files

This commit is contained in:
2015-06-25 16:28:41 -05:00
parent 656dca9289
commit eb27b55a54
5621 changed files with 1630154 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
/*
* daemonic-inheritance-test.js: Tests for configuration inheritance of forever.startDaemon()
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
spawn = require('child_process').spawn,
vows = require('vows'),
forever = require('../../lib/forever');
//
// n.b. (indexzero): The default root is `~/.forever` so this
// actually is a valid, non-default test path.
//
var myRoot = path.resolve(process.env.HOME, '.forever_root');
vows.describe('forever/core/startDaemon').addBatch({
"When using forever" : {
"the startDaemon() method with customized configuration" : {
topic: function () {
if (!fs.existsSync(myRoot)) {
fs.mkdirSync(myRoot);
}
forever.load({root:myRoot});
forever.startDaemon(path.join(__dirname, '..', 'fixtures', 'log-on-interval.js'));
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"should respond with 1 process": function (err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
},
"and logs/pids/socks are all piping into the customized root": function (err, procs) {
assert.equal(procs[0].logFile.indexOf(myRoot), 0);
assert.equal(procs[0].pidFile.indexOf(myRoot), 0);
assert.equal(procs[0].socket.indexOf(myRoot), 0);
}
}
}
}).addBatch({
"When the tests are over" : {
"stop all forever processes" : {
topic: function () {
forever.load({root:myRoot});
forever.stopAll().on('stopAll', this.callback.bind(null, null));
},
"should stop the correct number of procs": function (err, procs) {
assert.isArray(procs);
assert.lengthOf(procs, 1);
}
}
}
}).export(module);

View File

@@ -0,0 +1,60 @@
/*
* start-stop-relative.js: start or stop forever using relative paths, the script path could be start with './', '../' ...
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
spawn = require('child_process').spawn,
vows = require('vows'),
forever = require('../../lib/forever');
function runCmd(cmd, args) {
var proc = spawn(process.execPath, [
path.resolve(__dirname, '../../', 'bin/forever'),
cmd
].concat(args), {detached: true});
proc.unref();
}
vows.describe('forever/core/start-stop-peaceful').addBatch({
"When using forever" : {
"to run script with relative script path" : {
topic: function () {
runCmd('start', [
'./test/fixtures/log-on-interval.js'
]);
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"the startup should works fine": function (err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
}
}
}
}).addBatch({
"When the script is running" : {
"try to stop with relative script path" : {
topic: function () {
runCmd('stop', [
'./test/fixtures/log-on-interval.js'
]);
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"the shut down should works fine": function (err, procs) {
assert.isNull(err);
assert.isNull(procs);
}
}
}
}).export(module);

View File

@@ -0,0 +1,77 @@
/*
* stopall-peaceful-test.js: tests if `forever start` followed by `forever stopall` works.
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
spawn = require('child_process').spawn,
vows = require('vows'),
forever = require('../../lib/forever');
function runCmd(cmd, args) {
var proc = spawn(process.execPath, [
path.resolve(__dirname, '../../', 'bin/forever'),
cmd
].concat(args), {detached: true});
proc.unref();
return proc;
}
vows.describe('forever/core/stopall-peaceful').addBatch({
"When using forever" : {
"to run script with 100% exit" : {
topic: function () {
runCmd('start', [
'./test/fixtures/cluster-fork-mode.js'
]);
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"the script should be marked as `STOPPED`": function (err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
assert.ok(!procs[0].running);
}
}
}
}).addBatch({
"When the script is running" : {
"try to stop all" : {
topic: function () {
var that = this;
forever.list(false, function(err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
// get pid.
var pid = procs[0].pid;
// run command
var cmd = runCmd('stopall', []);
cmd.stdout.on('data', onData);
//listen on the `data` event.
function onData(data) {
// check whether pid exists or not.
var line = data.toString().replace (/[\n\r\t\s]+/g, ' ');
if (line && line.search(new RegExp(pid)) > 0) {
that.callback(null, true);
cmd.stdout.removeListener('data', onData);
}
// if pid did not exist, that means CLI has crashed, and no output was printed.
// vows will raise an Asynchronous Error.
}
});
},
"the shut down should works fine": function (err, peaceful) {
assert.isNull(err);
assert.ok(peaceful);
}
}
}
}).export(module);

View File

@@ -0,0 +1,78 @@
/*
* stopbypid-peaceful-test.js: tests if `forever start` followed by `forever stop <pid>` works.
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
spawn = require('child_process').spawn,
vows = require('vows'),
forever = require('../../lib/forever');
function runCmd(cmd, args) {
var proc = spawn(process.execPath, [
path.resolve(__dirname, '../../', 'bin/forever'),
cmd
].concat(args), {detached: true});
proc.unref();
return proc;
}
vows.describe('forever/core/stopbypid-peaceful').addBatch({
"When using forever" : {
"to run script with 100% exit" : {
topic: function () {
runCmd('start', [
'./test/fixtures/log-on-interval.js'
]);
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"the script should be running": function (err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
assert.ok(procs[0].running);
}
}
}
}).addBatch({
"When the script is running" : {
"try to stop by pid" : {
topic: function () {
var that = this;
forever.list(false, function(err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
// get pid.
var pid = procs[0].pid;
// run command
var cmd = runCmd('stop', [pid]);
cmd.stdout.on('data', onData);
cmd.stderr.pipe(process.stderr);
//listen on the `data` event.
function onData(data) {
// check whether pid exists or not.
var line = data.toString().replace (/[\n\r\t\s]+/g, ' ');
if (line && line.search(new RegExp(pid)) > 0) {
that.callback(null, true);
cmd.stdout.removeListener('data', onData);
}
// if pid did not exist, that means CLI has crashed, and no output was printed.
// vows will raise an Asynchronous Error.
}
});
},
"the shut down should works fine": function (err, peaceful) {
assert.isNull(err);
assert.ok(peaceful);
}
}
}
}).export(module);

47
node_modules/forever/test/core/tail-stopall-test.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
/*
* tail-stopall-test.js: Tests for forever.tail() and forever.stopAll()
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
spawn = require('child_process').spawn,
vows = require('vows'),
forever = require('../../lib/forever');
vows.describe('forever/core/tail').addBatch({
"When using forever": {
"the tail() method": {
topic: function () {
var that = this;
that.child = spawn('node', [path.join(__dirname, '..', 'fixtures', 'start-daemon.js')]);
setTimeout(function () {
forever.tail(0, { length: 1 }, that.callback);
}, 2000);
},
"should respond with logs for the script": function (err, procs) {
assert.isNull(err);
assert.equal(typeof procs, 'object');
assert.ok(procs.file);
assert.ok(procs.pid);
assert.ok(procs.line);
}
}
}
}).addBatch({
"When the tests are over": {
"stop all forever processes": {
topic: function () {
forever.stopAll().on('stopAll', this.callback.bind(null, null));
},
"should stop the correct number of procs": function (err, procs) {
assert.isArray(procs);
assert.lengthOf(procs, 1);
}
}
}
}).export(module);