1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 10:52:47 +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);