Skip to content

Commit

Permalink
Handle shutdown a bit more gracefully
Browse files Browse the repository at this point in the history
brundonsmith committed Dec 4, 2023
1 parent ea35a61 commit 4662b2d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions back-end/utils/db.ts
Original file line number Diff line number Diff line change
@@ -27,8 +27,13 @@ const db = new Pool({
}, env.DB_CONNECTION_POOL_SIZE)

function handleShutdown() {
console.log("Releasing DB connections")
db.end()
console.log("Releasing DB connections...")
try {
db.end()
console.log('connections released')
} catch {
console.log('connections had already been released')
}
}

Deno.addSignalListener('SIGINT', handleShutdown)

0 comments on commit 4662b2d

Please sign in to comment.