-
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.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* daemonic-inheritance-test.js: start or stop forever peaceful, 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); | ||
}, 1000, 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); | ||
}, 1000, this) | ||
}, | ||
"the shut down should works fine":function (err, procs) { | ||
assert.isNull(err); | ||
assert.isNull(procs); | ||
} | ||
} | ||
} | ||
}).export(module); |