     {:mesos-datomic mesos-datomic
      :route full-routes
      :http-server (fnk [[:settings server-port authorization-middleware [:rate-limit user-limit]] [:route view]]
-                       (log/info "Launching http server")
-                       (let [rate-limit-storage (storage/local-storage)
-                             jetty ((lazy-load-var 'qbits.jet.server/run-jetty)
-                                    {:port server-port
-                                     :ring-handler (-> view
-                                                       tell-jetty-about-usename
-                                                       (wrap-rate-limit {:storage rate-limit-storage
-                                                                         :limit user-limit})
-                                                       authorization-middleware
-                                                       wrap-stacktrace
-                                                       wrap-no-cache
-                                                       wrap-cookies
-                                                       wrap-params
-                                                       health-check-middleware
-                                                       instrument)
-                                     :join? false
-                                     :configurator configure-jet-logging
-                                     :max-threads 200
-                                     :request-header-size 32768})]
-                         (fn [] (.stop jetty))))
+                    (log/info "Launching http server")
+                    (let [rate-limit-storage (storage/local-storage)
+                          jetty ((lazy-load-var 'qbits.jet.server/run-jetty)
+                                  {:port server-port
+                                   :ring-handler (-> view
+                                                     tell-jetty-about-usename
+                                                     (wrap-rate-limit {:storage rate-limit-storage
+                                                                       :limit user-limit})
+                                                     authorization-middleware
+                                                     wrap-stacktrace
+                                                     wrap-no-cache
+                                                     wrap-cookies
+                                                     wrap-params
+                                                     health-check-middleware
+                                                     instrument)
+                                   :join? false
+                                   :configurator configure-jet-logging
+                                   :max-threads 200
+                                   :request-header-size 32768})]
+                      (fn [] (.stop jetty))))
 
      :framework-id (fnk [curator-framework [:settings mesos-leader-path]]
-                        (when-let [bytes (curator/get-or-nil curator-framework
-                                                             (str mesos-leader-path "/framework-id"))]
-                          (String. bytes)))
+                     (when-let [bytes (curator/get-or-nil curator-framework
+                                                          (str mesos-leader-path "/framework-id"))]
+                       (String. bytes)))
      :mesos-datomic-mult (fnk [mesos-datomic]
-                              (first ((lazy-load-var 'cook.datomic/create-tx-report-mult) mesos-datomic)))
+                           (first ((lazy-load-var 'cook.datomic/create-tx-report-mult) mesos-datomic)))
      :local-zookeeper (fnk [[:settings zookeeper-server]]
-                           (when zookeeper-server
-                             (log/info "Starting local ZK server")
-                             (.start zookeeper-server)))
+                        (when zookeeper-server
+                          (log/info "Starting local ZK server")
+                          (.start zookeeper-server)))
      :mesos mesos-scheduler
      :mesos-pending-jobs-atom (fnk [] (atom {}))
      :mesos-offer-cache (fnk [[:settings [:offer-cache max-size ttl-ms]]]

               (.getHostName (java.net.InetAddress/getLocalHost)))))

#_(def dev-mem-settings
  {:server-port (fnk [] 12321)
   :authorization-middleware (fnk [] (fn [h] (fn [req] (h (assoc req :authorization/user (System/getProperty "user.name"))))))
   :sim-agent-path (fnk [] "/usr/bin/sim-agent") ;;TODO parameterize
   :mesos-datomic-uri (fnk [] "datomic:mem://mesos-jobs")
   :dns-name simple-dns-name
   :zookeeper (fnk []
                   "localhost:3291")
   :zookeeper-server (fnk []
                          (org.apache.curator.test.TestingServer. 3291 true) ;; Start a local ZK for simplicity
                          )
   :hostname (fnk [] (.getCanonicalHostName (java.net.InetAddress/getLocalHost)))
   :offer-incubate-time-ms (fnk [] (* 15 1000))
   :task-constraints (fnk []
                          {:timeout-hours 1
                           :timeout-interval-minutes 1
                           :memory-gb 48
                           :cpus 6
                           :retry-limit 5})
   ;:task-constraints (fnk []
   ;                       {:timeout-hours (* 5 24)
   ;                        :timeout-interval-minutes 10
   ;                        :memory-gb 128
   ;                        :cpus 24})
   :mesos-master (fnk [] "zk://localhost:2181/mesos")
   :mesos-failover-timeout (fnk [] nil) ; don't fail over
   ;:mesos-failover-timeout (fnk [] (* 1.0
   ;                                   3600  ; seconds/hour
   ;                                   24    ; hours/day
   ;                                   7     ; days/week
   ;                                   2     ; weeks
   ;                                   ))
   :mesos-leader-path (fnk [] (str "/cook-scheduler"))
   :mesos-principal (fnk [] nil) ;; You can change this to customize for your environment
   :exception-handler (fnk [] ((lazy-load-var 'cook.util/install-email-on-exception-handler))) ;;TODO parameterize
   })

(def default-authorization {:authorization-fn 'cook.authorization/open-auth})


  ([{:keys [file] :or {file "log/cook.log"} {:keys [default] :or {default :info} :as overrides} :levels}]
   (try
     (.. (org.apache.log4j.Logger/getRootLogger)
         (getLoggerRepository)
         (resetConfiguration))
     ;; This lets you inspect which loggers have which appenders turned on
     ;;(clojure.pprint/pprint (map #(select-keys % [:allAppenders :name]) (log4j-conf/get-loggers)))
     (let [overrides (->> overrides
                          (filter (comp string? key))
                          (mapcat (fn [[logger level]]
                                    [[logger] {:level level}])))]
       (apply log4j-conf/set-loggers!
              (org.apache.log4j.Logger/getRootLogger)
              {:out (org.apache.log4j.DailyRollingFileAppender.
                      (org.apache.log4j.PatternLayout.
                        "%d{ISO8601} %-5p %c [%t] - %m%n")
                      file
                      "'.'yyyy-MM-dd")
               :level default}
              overrides))
     (catch Throwable t
       (.println System/err "Failed to initialize logging!")
       (.printCauseTrace t)
