Fix runtime stats sending

pull/154/head
Maciej Winnicki 2018-11-28 10:13:32 +01:00
parent 28de6d18dc
commit c35287ce7a
No known key found for this signature in database
GPG Key ID: 035AA4FA2183ADFA
2 changed files with 5 additions and 4 deletions

View File

@ -157,8 +157,9 @@ if (program.daemonize) {
* Handle signals
*/
const cleanExit = () => {
stats.timeEnd('runtime', 'runtime');
process.exit();
stats.timeEnd('runtime', 'runtime', () => {
process.exit();
});
};
process.on('SIGINT', cleanExit);
process.on('SIGTERM', cleanExit);

View File

@ -54,12 +54,12 @@ Stats.prototype.time = function time(category, action) {
this.timer[category][action] = Date.now();
};
Stats.prototype.timeEnd = function timeEnd(category, action) {
Stats.prototype.timeEnd = function timeEnd(category, action, cb) {
if (!this.tracker) {
return;
}
this.tracker.timing(category, action, Date.now() - this.timer[category][action]).send();
this.tracker.timing(category, action, Date.now() - this.timer[category][action]).send(cb);
};
module.exports = enabled => new Stats(enabled);