yada

mccraigmccraig 2018-03-22T00:00:58.000359Z

cool!

mccraigmccraig 2018-03-22T00:03:12.000105Z

generally don't rely on rebinding vars (with def or defn) to hold application state - use an atom or an agent instead, and note the defonce which avoids recompilation wiping out your state

2018-03-22T00:19:22.000267Z

Yeah I started off with defonce but it was still causing the "CompilerException java.net.BindException: Address already in use" exception. I took what you gave me and somewhat changed it but the core is the same.

(defn start! []
  (if (nil? @server)
    (do
      (println "Starting server...")
      (reset! server (resource-routes)))
    (do
      (println "Server already running.")
      @server)))

(defn stop! []
  (when (:close @server)
    (do
      (println "Closing server...")
      (reset! server ((:close @server))))))


(defn reload! []
  (do
    (println "Reloading server...")
    (stop!)
    (start!)))