mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
895 B
43 lines
895 B
11 years ago
|
var assert = require('assert');
|
||
|
var net = require('net');
|
||
|
var util = require('util');
|
||
10 years ago
|
var common = require('../common');
|
||
11 years ago
|
var revivals = 0;
|
||
|
var deaths = 0;
|
||
|
|
||
|
process.on('beforeExit', function() { deaths++; } );
|
||
|
|
||
|
process.once('beforeExit', tryImmediate);
|
||
|
|
||
|
function tryImmediate() {
|
||
|
console.log('set immediate');
|
||
|
setImmediate(function() {
|
||
|
revivals++;
|
||
|
process.once('beforeExit', tryTimer);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function tryTimer() {
|
||
|
console.log('set a timeout');
|
||
|
setTimeout(function () {
|
||
|
console.log('timeout cb, do another once beforeExit');
|
||
|
revivals++;
|
||
|
process.once('beforeExit', tryListen);
|
||
|
}, 1);
|
||
|
}
|
||
|
|
||
|
function tryListen() {
|
||
|
console.log('create a server');
|
||
|
net.createServer()
|
||
10 years ago
|
.listen(common.PORT)
|
||
11 years ago
|
.on('listening', function() {
|
||
|
revivals++;
|
||
|
this.close();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
process.on('exit', function() {
|
||
|
assert.equal(4, deaths);
|
||
|
assert.equal(3, revivals);
|
||
|
});
|