Skip to content

Instantly share code, notes, and snippets.

@bnyeggen
Last active December 27, 2015 14:29
Show Gist options
  • Save bnyeggen/7341384 to your computer and use it in GitHub Desktop.
Save bnyeggen/7341384 to your computer and use it in GitHub Desktop.
Running a Compojure app with a main function via java -jar
(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}))
(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")
#!/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