How to test the connection & cleanup on shutdown
I'm using drizzle in an express server, I have cleanup code listening for
SIGTERM
and SIGINT
that will close the server, how can I tell drizzle to close all the connections to the database? And while I'm at it I would like to test the connection as soon as the server starts, because we are using AWS managed database. I would like to know if I can connect from this server to the database, if not then there is no point in running the server.2 Replies
You should look at the “client” (driver) you use to create your db object (drizzle(xx)).
You can export the client and invoke its own methods (not sure they all have something to close the connection).
To warmup your db connection, you can execute a raw sql like
I was using only the drizzle db object, if there is no way to test the connection through drizzle then yes I will have to look at testing the underlying connection
which means I will have to export the connection as well (not sure if our team would want to do that)