How do I close connection pooling created with the mysql module when the console ctrl+c shuts down express?

I need to do a game background, but I don"t know much about the back-end part, so I"d like to ask the following people.
I created the connection pool with the mysql module, and I see in the document that if you don"t call pool.end () to close the connection pool, the connection will remain until the mysql server shuts down.
looks at express"s documentation and doesn"t seem to have any events when the server shuts down.
so please tell me what I should do to ensure that connection pooling is properly closed when I turn on and off the server?

Mar.11,2021

process.on('exit', (code) => {
   //do what you want
});
Menu