Skip to content

Commit a737478

Browse files
committed
close connections
1 parent cf06389 commit a737478

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: src/utils/dbConnection.js

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ const connect = async () => {
3333
return conn;
3434
};
3535

36+
// SIGTERM Handler
37+
// from https://github.com/aws-samples/graceful-shutdown-with-aws-lambda
38+
process.on('SIGTERM', async () => {
39+
console.info('[runtime] SIGTERM received');
40+
41+
console.info('[runtime] cleaning up');
42+
if(conn !== null){
43+
let realConn = await conn
44+
await realConn.$pool.end()
45+
}
46+
47+
console.info('[runtime] exiting');
48+
process.exit(0)
49+
});
50+
3651
module.exports = {
3752
pgp,
3853
connect,

0 commit comments

Comments
 (0)