Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(def server-state (atom nil))
(defmulti server-control identity)
(defmethod server-control :start
[& config]
(if @server-state
(println "START: Aborting, already initialized. Use :restart")
(let [handler (:handler config)]
(println "START: Starting server...")
(swap! server-state (fn [_] (start-tcp-server handler {:port 3000})))
(println "START: Startup complete"))))
(defmethod server-control :stop
[& config]
(when @server-state
(println "Shutting down server...")
(swap! server-state (fn [_] nil))))
(println "Shutdown complete."))
(defmethod server-control :restart
[& config]
( :stop)
(println "server stopped -- reinitializing")
(use :reload-all '
(println "reloaded namespace")
( :start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.