code good so far

This commit is contained in:
Joe Tretter
2018-09-18 12:58:41 -05:00
parent 339333625d
commit 008a4df31e
3 changed files with 27 additions and 33 deletions

View File

@@ -43,7 +43,7 @@ let close = () => {
});
}
let main = async () => {
/* let main = async () => {
query('insert into log (message) values (\'Outside\')');
let rows = null;
try {
@@ -56,14 +56,21 @@ let main = async () => {
} catch (ex) {
console.error('Error', ex);
}
}
main(); */
let exitHandler = (eventType) => {
console.log("DB-Cleaning up (" + eventType + ")");
close();
}
main();
// make sure we close the DB in case the process ends.
[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `uncaughtException`, `SIGTERM`].forEach((eventType) => {
process.on(eventType, exitHandler.bind(null, eventType));
})
module.exports = {
query,
close
query
};