Skip to content

Instantly share code, notes, and snippets.

@LuminousMonkey
Created April 26, 2012 02:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LuminousMonkey/2495345 to your computer and use it in GitHub Desktop.
Save LuminousMonkey/2495345 to your computer and use it in GitHub Desktop.
(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])
(:gen-class))
(def ^:dynamic *port* 8081)
(defonce server (atom nil))
(defn stop
"Stops the web application."
[]
(if-not (nil? @server)
(do
(.stop @server)
(reset! server nil))))
(defn start
"Starts or restarts the web application.
From a REPL:
(require 'interface.boot)
(interface.boot/start)"
[]
(stop)
(let [handler (wrap-stacktrace #'routes/app-routes)
s (run-jetty handler {:port *port* :join? false})]
(reset! server s)))
(defn restart
"Restarts the web application."
[]
(start))
(defn -main
[]
(start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment