Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(ns interface.boot
"This namespace is only used while developing
to start and stop an internal webserver."
(:use [ring.adapter.jetty :only [run-jetty]]
[ring.middleware.stacktrace :only [wrap-stacktrace]])
(:require [interface.routes :as routes])
(def ^:dynamic *port* 8081)
(defonce server (atom nil))
(defn stop
"Stops the web application."
(if-not (nil? @server)
(.stop @server)
(reset! server nil))))
(defn start
"Starts or restarts the web application.
From a REPL:
(require 'interface.boot)
(let [handler (wrap-stacktrace #'routes/app-routes)
s (run-jetty handler {:port *port* :join? false})]
(reset! server s)))
(defn restart
"Restarts the web application."
(defn -main
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.