You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing around with this library.
I want to implement a small application which needs a "proper" shutdown. Unfortunately I don't get it working.
I feel it has something to do with this library...
This is the code:
const ExclusiveKeyboard = require('exclusive-keyboard');
var keyboard = new ExclusiveKeyboard("event6", false);
keyboard.on('error', keyboardError);
keyboard.on('keypress', keydown);
keyboard.on('close', keyboardClose);
function keyboardError(error) {
console.error("Got keyboard error %s", error)
}
function keyboardClose() {
console.log("Keyboard closed");
}
function keydown(keyboardEvent) {
var keyId = keyboardEvent.keyId
console.log(keyId)
}
function handleExit(signal) {
console.log(`Received ${signal}. Close my server properly.`)
keyboard.close();
keyboard = undefined;
setTimeout(function () {
console.log("Will stop now");
process.exit(0);
}, 1000);
}
process.on('SIGINT', handleExit);
process.on('SIGQUIT', handleExit);
process.on('SIGTERM', handleExit);
When you now run the app and hit <ctl+c> it prints:
^CReceived SIGINT. Close my server properly.
Keyboard closed
Will stop now
But it never really stops. I have to kill it using kill -9 <pid>
If I remove handleExit and following code, it works fine.
Any idea what could be the issue here?
The text was updated successfully, but these errors were encountered:
Hello,
I'm playing around with this library.
I want to implement a small application which needs a "proper" shutdown. Unfortunately I don't get it working.
I feel it has something to do with this library...
This is the code:
When you now run the app and hit <ctl+c> it prints:
But it never really stops. I have to kill it using
kill -9 <pid>
If I remove
handleExit
and following code, it works fine.Any idea what could be the issue here?
The text was updated successfully, but these errors were encountered: