Last active
December 27, 2015 14:29
-
-
Save bnyeggen/7341384 to your computer and use it in GitHub Desktop.
Running a Compojure app with a main function via java -jar
This file contains 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 myproject.core | |
(:use compojure.core) | |
(:require [compojure.route :as route] | |
[compojure.handler :as handler] | |
[ring.adapter.jetty :as ring-jetty]) | |
(:gen-class)) | |
(defroutes my-routes | |
(GET "/" [] "<h1>Hello World</h1>") | |
(route/not-found "<h1>Page not found</h1>")) | |
(def app (handler/site my-routes)) | |
(defn -main [& args] | |
(println "I parse my arguments" args) | |
(ring-jetty/run-jetty app {:port 8080})) |
This file contains 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
(defproject myproject "0.1.0-SNAPSHOT" | |
:description "???" | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[compojure "1.1.6"] | |
[ring "1.2.1"]] | |
:main myproject.core | |
:uberjar-name "myproject.jar") |
This file contains 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
#!/bin/bash | |
lein uberjar && java -jar target/myproject.jar important arguments & | |
sleep 5 | |
curl localhost:8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment