             [compojure.route :refer [not-found resources]]
             [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
             [selmer.parser :refer [render-file]]
+            [cheshire.core :refer [generate-string]]
             [environ.core :refer [env]]
             [prone.middleware :refer [wrap-exceptions]]))
 

           (render-file "templates/index.html" {:dev (env :dev?)}))

      (GET "/cluster-stats" [] (to-transit @stats))
      (GET "/stats" [] @stats)
      (resources "/")
      (not-found "Not Found"))))


  (when-not @collecting?
    (let [interval (or (env :refresh-interval) 4)]
      (info "[hface]: scheduling cluster stats collector to run every " interval " seconds")
      (if (env :dev?) 
        (doall (cluster-of 1)))                                      ;; in dev mode start a one node cluster
      (collect-stats interval)
      (reset! collecting? true))))

