diff --git a/src/wanijo/main.clj b/src/wanijo/main.clj index c215d69..3a3a212 100644 --- a/src/wanijo/main.clj +++ b/src/wanijo/main.clj @@ -3,7 +3,26 @@ [wanijo.handler :as wanijo]) (:gen-class)) +(defonce server (atom nil)) + +(defn start-server! + [& {:keys [port + join?] + :or {port 3080 + join? true}}] + (reset! server + (run-jetty wanijo/standalone-app + {:port port + :join? join?}))) + +(defn start-server-dev! [] + (start-server! :join? false + :port 8080)) + +(defn stop-server [] + (.stop @server)) + (defn -main [& args] - (run-jetty wanijo/standalone-app - {:port (Integer/valueOf (or (System/getenv "port") - "3080"))})) + (start-server! :port (Integer/valueOf (or (System/getenv "port") + "3080")) + :join? false))