                          :modules modules/default-manager
                          :fs deployer/directory
                          :repl repl/nrepl]
-    (run systems))
+    ((if daemon? run-daemon #_else run) systems))
+  (println "Shutting down...")
   (shutdown-agents)
   (shutdown-timer 10))

  (deployer/bootstrap-modules (:fs sys))
  (command-loop sys))


(defn -main
  [& args]
  (with-systems systems [:config (config/file-config (as-file (resource "spec.clj")))
                         :cassandra cassandra/embedded12
                         :elastic elastic/embedded

                                   (interpose "\n  " threads))))))]
    (.schedule timer task (int (* wait 1000)))))

;;; Daemon control

(def daemon-latch (java.util.concurrent.CountDownLatch. 1))
(defn shutdown []
  (println "Received kill.")
  (.countDown daemon-latch)
  (Thread/sleep 1337))

;;; The coordinating functions.

