Skip to content
This repository
Browse code

Runs everywhere, even on Heroku.

  • Loading branch information...
commit ec04b39acd9fce81035dbdffbdeda39414925d46 1 parent a618c4d
Anthony Grimes authored

Showing 2 changed files with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +2 0  project.clj
  2. +9 2 src/tryclojure/core.clj
2  project.clj
@@ -4,5 +4,7 @@
4 4 [noir "1.2.0"]
5 5 [commons-lang/commons-lang "2.5"]
6 6 [clojail "0.4.6-beta4"]]
  7 + ;; For lein and Heroku compatibility. If you're using cake, add
  8 + ;; this line to .cake/config: jvm.opts = -Djava.security.policy=example.policy
7 9 :jvm-opts ["-Djava.security.policy=example.policy"]
8 10 :main tryclojure.core)
11 src/tryclojure/core.clj
@@ -140,6 +140,13 @@
140 140
141 141 (server/add-middleware wrap-file (System/getProperty "user.dir"))
142 142
143   -(defn tryclj [] (server/start (Integer. (System/getenv "PORT"))))
  143 +(defn to-port [s]
  144 + (when-let [port s] (Long. port)))
144 145
145   -(defn -main [& args] (tryclj))
  146 +(defn tryclj [port]
  147 + (server/start
  148 + (or (to-port port)
  149 + (to-port (System/getenv "PORT")) ;; For deploying to Heroku
  150 + 8801)))
  151 +
  152 +(defn -main [& args] (tryclj (first args)))

0 comments on commit ec04b39

Please sign in to comment.
Something went wrong with that request. Please try again.