code good so far
This commit is contained in:
17
database.js
17
database.js
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user