I've got HikariCP running in my clojure ring app for connection pooling. The problem is I don't know of a good place to close the pool so I'm not. I allow the pool to die when the app does and never explicitly close it. It appears this is leaking connections whenever I redeploy my app to Elastic Beanstalk (which is using Tomcat) but I'm not totally sure. I'm wondering where (if anywhere) is a good place to put app shut down code so I can explicity close my connection pool. FYI, current deployment process is to execute lein ring uberwar
and deploy that war via the elasticbeanstalk UI.
In your project.clj :ring
definition where you specify a :handler
, you can also specify :init
and :destroy
keys, with functions that take no arguments which will be called on startup (for :init) and destruction (:destroy) of your servlet.
project.clj:
:ring {:handler hello-world.core/handler
:init hello-world.core/setup-connectionpool
:destroy hello-world.core/shutdown-connectionpool}
See the lein-ring documentation