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

pushed new blog post

This commit is contained in:
2015-10-28 14:37:06 -04:00
parent 77e382c5f1
commit 2e2b29eac1
602 changed files with 63133 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
/*
* start-stop-json-test.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'),
vows = require('vows'),
async = require('utile').async,
request = require('request'),
forever = require('../../lib/forever'),
runCmd = require('../helpers').runCmd;
vows.describe('forever/core/start-stop-json-array').addBatch({
"When using forever" : {
"to start process using JSON configuration file containing an array" : {
topic: function () {
runCmd('start', [
'./test/fixtures/servers.json'
]);
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, 2);
}
}
}
}).addBatch({
"When the script is running": {
"request to both ports": {
topic: function () {
async.parallel({
one: async.apply(request, { uri: 'http://localhost:8080', json: true }),
two: async.apply(request, { uri: 'http://localhost:8081', json: true })
}, this.callback);
},
"should respond correctly": function (err, results) {
assert.isNull(err);
assert.isTrue(!results.one[1].p);
assert.equal(results.two[1].p, 8081);
}
}
}
}).addBatch({
"When the script is running" : {
"try to stopall" : {
topic: function () {
runCmd('stopall', []);
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,51 @@
/*
* start-stop-json-test.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'),
vows = require('vows'),
forever = require('../../lib/forever'),
runCmd = require('../helpers').runCmd;
vows.describe('forever/core/start-stop-json-obj').addBatch({
"When using forever" : {
"to start process using JSON configuration file containing an object" : {
topic: function () {
runCmd('start', [
'./test/fixtures/server.json'
]);
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 by uid" : {
topic: function () {
runCmd('stop', [
'server'
]);
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);

6
node_modules/forever/test/fixtures/server.json generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"uid": "server",
"append": true,
"script": "server.js",
"sourceDir": "./test/fixtures"
}

15
node_modules/forever/test/fixtures/servers.json generated vendored Normal file
View File

@@ -0,0 +1,15 @@
[
{
"uid": "server1",
"append": true,
"script": "server.js",
"sourceDir": "./test/fixtures"
},
{
"uid": "server2",
"append": true,
"script": "server.js",
"sourceDir": "./test/fixtures",
"args": ["-p", 8081]
}
]

31
node_modules/forever/test/helpers/index.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/*
* index.js: Test helpers for forever.
*
* (C) 2015 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var path = require('path'),
spawn = require('child_process').spawn;
/*
* function runCmd (cmd, args)
* Executes forever with the `cmd` and arguments.
*/
exports.runCmd = function runCmd(cmd, args) {
var proc = spawn(process.execPath, [
path.resolve(__dirname, '../../', 'bin/forever'),
cmd
].concat(args), {detached: true});
//
// Pipe everything to `stderr` so it can
// be seen when running `npm test`.
//
proc.stdout.pipe(process.stderr);
proc.stderr.pipe(process.stderr);
proc.unref();
return proc;
}