Commit ec2ede80 authored by Ryan Senior's avatar Ryan Senior

Merge pull request #1324 from rbrw/ticket/master/clean-up-bonecp-resources

(maint) Clean up BoneCP resources when finished
parents 0a322036 807e7b11
......@@ -202,19 +202,22 @@
(mq/stop-broker! broker)))
(defn stop-puppetdb
(log/info "Shutdown request received; puppetdb exiting.")
(shutdown-mq context)
(defn error-shutdown!
"Last-resort shutdown/cleanup code to execute when a fatal error has occurred."
(log/error "A fatal error occurred; shutting down all subsystems.")
"Shuts down PuppetDB, releasing resources when possible.  If this is
not a normal shutdown, emergency? must be set, which currently just
produces a fatal level level log message, instead of info."
[context emergency?]
(if emergency?
(log/error "A fatal error occurred; shutting down all subsystems.")
(log/info "Shutdown request received; puppetdb exiting."))
(when-let [updater (context :updater)]
(log/info "Shutting down updater thread.")
(future-cancel updater))
(shutdown-mq context))
(shutdown-mq context)
(when-let [ds (get-in context [:shared-globals :scf-write-db :datasource])]
(.close ds))
(when-let [ds (get-in context [:shared-globals :scf-read-db :datasource])]
(.close ds))
(defn add-max-framesize
"Add a maxFrameSize to broker url for activemq."
......@@ -305,7 +308,7 @@
(future (shutdown-on-error
(service-id service)
#(maybe-check-for-updates product-name update-server read-db)
#(stop-puppetdb % true))))
context (if updater
(assoc context :updater updater)
......@@ -357,7 +360,7 @@
(start-puppetdb context (get-config) this add-ring-handler get-route shutdown-on-error))
(stop [this context]
(stop-puppetdb context))
(stop-puppetdb context false))
(shared-globals [this]
(:shared-globals (service-context this)))
(query [this query-obj version query-expr paging-options row-callback-fn]
......@@ -422,7 +422,8 @@
(doseq [db dbs]
(sql/with-connection db
(sql/do-commands "SHUTDOWN"))))
(sql/do-commands "SHUTDOWN"))
(.close (:datasource db))))
(deftestseq fact-queries
[[version endpoint] facts-endpoints]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment