Skip to content

Commit

Permalink
[fix] CTRL+C should shut down all workers.
Browse files Browse the repository at this point in the history
[fix] Always calculate the established
[fix] Metrics always rerturns `this`
  • Loading branch information
3rd-Eden committed Apr 7, 2013
1 parent 838327c commit 274de8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/thor
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ async.forEach(cli.args, function forEach(url, done) {

console.log('');

process.once('SIGINT', process.exit.bind(process, 0));
process.once('SIGINT', function end() {
robin.forEach(function nuke(worker) {
try { worker.send({ shutdown: true }); }
catch (e) {}
})
});

process.once('exit', function summary() {
metrics.stop().summary();
metrics.established().stop().summary();
});
5 changes: 5 additions & 0 deletions metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ Metrics.prototype.stop = function stop() {
* @api public
*/
Metrics.prototype.established = function established() {
if (this.timing.established) return this;

this.timing.ready = Date.now();
this.timing.established = this.timing.ready - this.timing.start;
return this;
};

/**
Expand Down Expand Up @@ -247,6 +250,8 @@ Metrics.prototype.summary = function summary() {
results.writeRow([this.errors[err] +'x', err]);
}, this);
}

return this;
};

//
Expand Down

0 comments on commit 274de8d

Please sign in to comment.