add main init/shutdown to start/stop logging if logger option is given

This commit is contained in:
Gered 2016-05-21 15:59:22 -04:00
parent 323e7497c3
commit 2faf596777

View file

@ -384,7 +384,7 @@
and instead manually initialize the view system themselves. Some of the and instead manually initialize the view system themselves. Some of the
defaults set by this function are only appropriate for non-distributed defaults set by this function are only appropriate for non-distributed
configurations." configurations."
[& {:keys [refresh-interval worker-threads send-fn put-hints-fn auth-fn namespace-fn views] [& {:keys [refresh-interval worker-threads send-fn put-hints-fn auth-fn namespace-fn views stats-log-interval]
:or {refresh-interval 1000 :or {refresh-interval 1000
worker-threads 4 worker-threads 4
put-hints-fn #(refresh-views! %)}}] put-hints-fn #(refresh-views! %)}}]
@ -393,6 +393,9 @@
(if auth-fn (set-auth-fn! auth-fn)) (if auth-fn (set-auth-fn! auth-fn))
(if namespace-fn (set-namespace-fn! namespace-fn)) (if namespace-fn (set-namespace-fn! namespace-fn))
(if views (add-views! views)) (if views (add-views! views))
(when stats-log-interval
(swap! view-system assoc :logging? true)
(start-logger! stats-log-interval))
(start-update-watcher! refresh-interval worker-threads)) (start-update-watcher! refresh-interval worker-threads))
(defn shutdown! (defn shutdown!
@ -400,4 +403,6 @@
all view subscriptions and data." all view subscriptions and data."
[] []
(stop-update-watcher!) (stop-update-watcher!)
(if (:logging? @view-system)
(stop-logger!))
(reset! view-system {})) (reset! view-system {}))