I am new to clojure. My question is: Whats the common practice when it comes to deploying webapps built on compojure? running via lein ring server or creating a war file ? I would also like to know which is the best way to put load configuration files i.e using properties file... or using a reader to load .clj file with a hashmap def?
I recommend simply embedding jetty and writing a -main function that
uses run-jetty. Then you can just ship an uberjar out to deploy.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
John Gabriele writes:
> What would I need to do in order to embed jetty so I can create an uberjar
> (`lein uberjar`) and deploy it (I suppose via: `java -jar
> my-webapp-0.1.0-standalone.jar &`)?
>
> What would need to be added to / changed in the project.clj?
>
> What exactly should the `-main` look like?
All it takes is this in project.clj:
[ring/ring-jetty-adapter "1.1.6"]
and this in main.clj:
(defn -main [& [port]]
(let [port (Integer. (or port (System/getenv "PORT") 5000))]
(jetty/run-jetty #'app {:port port :join? false}))))
On Wednesday, January 9, 2013 4:08:50 PM UTC-5, Phil Hagelberg wrote:
and this in main.clj:
(defn -main [& [port]]
(let [port (Integer. (or port (System/getenv "PORT") 5000))]
(jetty/run-jetty #'app {:port port :join? false}))))
Ok. That also meant I had to add the bare `jetty` to the ns's :require.
Still though, need to add a :main to project.clj I think.
On Wednesday, January 9, 2013 4:08:50 PM UTC-5, Phil Hagelberg wrote:
John Gabriele writes:
and this in main.clj:
(defn -main [& [port]]
(let [port (Integer. (or port (System/getenv "PORT") 5000))]
(jetty/run-jetty #'app {:port port :join? false}))))
~~~clojure
(defproject my-webapp "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.4.0"]
[compojure "1.1.3"]
[ring/ring-jetty-adapter "1.1.6"]]
:plugins [[lein-ring "0.7.5"]]
:ring {:handler my-webapp.handler/app}
:profiles
{:dev {:dependencies [[ring-mock "0.1.3"]]}}
)
~~~
I'm guessing there's a `:main` missing in there. What should its value be?
On Wed, Jan 9, 2013 at 4:27 PM, John Gabriele <jmg...@gmail.com> wrote:On Wednesday, January 9, 2013 4:08:50 PM UTC-5, Phil Hagelberg wrote:
John Gabriele writes:
and this in main.clj:
(defn -main [& [port]]
(let [port (Integer. (or port (System/getenv "PORT") 5000))]
(jetty/run-jetty #'app {:port port :join? false}))))What namespace is main.clj defining? It needs to have :gen-class added to it.Minimally, it could be(ns my-webapp.main[[some dependencies here]]:gen-class)