-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api test] Added
forever logs
CLI commands and forever.tail()
met…
- Loading branch information
Showing
6 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
setInterval(function () { | ||
console.log('Logging at ' + Date.now()); | ||
}, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* start-daemon.js: Simple test fixture for spawning log-on-interval.js as a daemon | ||
* | ||
* (C) 2010 Nodejitsu Inc. | ||
* MIT LICENCE | ||
* | ||
*/ | ||
|
||
var path = require('path'), | ||
forever = require('../../lib/forever'); | ||
|
||
var monitor = forever.startDaemon(path.join(__dirname, '..', '..', 'examples', 'log-on-interval.js')); | ||
|
||
monitor.on('start', function () { | ||
forever.startServer(monitor); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* forever-test.js: Tests for forever module | ||
* | ||
* (C) 2010 Nodejitsu Inc. | ||
* MIT LICENCE | ||
* | ||
*/ | ||
|
||
var assert = require('assert'), | ||
path = require('path'), | ||
spawn = require('child_process').spawn, | ||
vows = require('vows'), | ||
forever = require('../lib/forever'), | ||
helpers = require('./helpers'); | ||
|
||
vows.describe('forever/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, that.callback); | ||
}, 2000); | ||
}, | ||
"should respond with logs for the script": function (err, procs) { | ||
assert.isNull(err); | ||
assert.isArray(procs); | ||
procs.forEach(function (proc) { | ||
assert.isArray(proc.logs); | ||
assert.isTrue(!!proc.logs.length); | ||
assert.isTrue(proc.logs.length > 10); | ||
}) | ||
} | ||
} | ||
} | ||
}).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.length(procs, 1); | ||
} | ||
} | ||
} | ||
}).export(module); |