Last active
November 11, 2022 13:23
-
-
Save GreepTheSheep/a7a2619d6ed2541338db4dca14a9af2f to your computer and use it in GitHub Desktop.
Exit commands on Node.js with MariaDB backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.on('SIGINT', exit); // CTRL+C | |
process.on('SIGQUIT', exit); // Keyboard quit | |
process.on('SIGTERM', kill); // `kill` command | |
process.on('SIGWINCH', exit); // docker down or else idk | |
function exit() { | |
console.log("Exiting..."); | |
DB.end().then(process.exit(0)) | |
.catch(err=>{ | |
console.error("MariaDB End connexion error:", err); | |
process.exit(1); | |
}); | |
} | |
function kill() { | |
console.log("SIGTERM received, killing connexion..."); | |
DB.end(true).then(process.exit(0)) | |
.catch(err=>{ | |
console.error("MariaDB End connexion error:", err); | |
process.exit(1); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment