Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not shutting down via signals if usage reporting is disabled #160

Closed
apeteri opened this issue Feb 11, 2019 · 4 comments
Closed

Not shutting down via signals if usage reporting is disabled #160

apeteri opened this issue Feb 11, 2019 · 4 comments
Labels

Comments

@apeteri
Copy link

apeteri commented Feb 11, 2019

Hi Maciej,

I am using release 4.5.3 with a systemd service script, and I have noticed that the service waits for the whole ~90 second grace period when stopping, before it gets killed forcefully. Systemd attempts to stop a service by sending SIGTERM to its process group by default.

It seems that the callback for usage stats reporting in stats.js is not invoked if no tracker instance exists:

frontail/lib/stats.js

Lines 57 to 63 in 205cdbf

Stats.prototype.timeEnd = function timeEnd(category, action, cb) {
if (!this.tracker) {
return;
}
this.tracker.timing(category, action, Date.now() - this.timer[category][action]).send(cb);
};

Due to this, signals have no effect at the end of index.js:

frontail/index.js

Lines 159 to 165 in 205cdbf

const cleanExit = () => {
stats.timeEnd('runtime', 'runtime', () => {
process.exit();
});
};
process.on('SIGINT', cleanExit);
process.on('SIGTERM', cleanExit);

Regards,
András

@apeteri
Copy link
Author

apeteri commented Feb 15, 2019

Possible duplicate of #158.

@mthenw
Copy link
Owner

mthenw commented Feb 20, 2019

Thanks for reporting. I will take a look.

@mthenw mthenw added the bug label Feb 21, 2019
mthenw added a commit that referenced this issue Feb 21, 2019
@mthenw
Copy link
Owner

mthenw commented Feb 21, 2019

I released new version v.4.5.4. Please confirm that it works now.

@mthenw mthenw closed this as completed Feb 21, 2019
@apeteri
Copy link
Author

apeteri commented Mar 1, 2019

Looks good, now the process stops immediately. Thanks! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants