Update : This question has changed since the original set of commentators left answers. I apologize for any confusion.
This is my code repository https://github.com/Integralist/spurious-clojure-example you can use it as an example of what I'm working with.
Please note that the above repo relies on a library that I haven't published in Clojars yet (since I'm still testing it, so this question was open). You can see the source code of the library here: https://github.com/Integralist/spurious-clojure-aws-sdk-helper
I have a Clojure hello world web application written in Compojure that works fine when I start with lein ring serverand lein run(since now I have a function -main). It also works to a certain extent when compiled into a jar, and I run java -jar app.jar.
My problem is that if I try to start the default java -jar app.jarfrom the Docker container, I get the following error telling me ...
spurious-clojure-example is starting
2015-02-14 00:58:03.812:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT
2015-02-14 00:58:03.854:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
Started server on port 8080
Exception in thread "main" java.awt.HeadlessException:
My code is currently using a function -mainlike ...
(ns spurious-clojure-example.repl
(:use spurious-clojure-example.handler
ring.server.standalone
[ring.middleware file-info file])
(:gen-class))
(defonce server (atom nil))
(defn get-handler []
(->
(wrap-file "resources")
(wrap-file-info)))
(defn start-server
"used for starting the server in development mode from REPL"
[& [port]]
(let [port (if port (Integer/parseInt port) 8080)]
(reset! server
(serve (get-handler)
{:port port
:init init
:auto-reload? true
:destroy destroy
:join true}))
(println (str "You can view the site at http://localhost:" port))))
(defn stop-server []
(.stop @server)
(reset! server nil))
(defn -main []
(start-server))
... but how can I get the server to start without a head? I can’t fully follow the Compojure pattern to decipher where and how it knows when to run headless or through a browser?
I know that on the command line you can make lein ring server-headlessit the software equivalent?