Created
April 26, 2012 02:51
-
-
Save LuminousMonkey/2495345 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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