Selaa lähdekoodia

web-backend uses provided port. tested in marathon :)

Harlan Iverson 8 vuotta sitten
vanhempi
commit
df9540a57a
3 muutettua tiedostoa jossa 16 lisäystä ja 6 poistoa
  1. 2 1
      web-backend/project.clj
  2. 3 3
      web-backend/src/example/core.clj
  3. 11 2
      web-backend/src/example/main.clj

+ 2 - 1
web-backend/project.clj

@@ -2,7 +2,8 @@
             :dependencies [[org.clojure/clojure :clj1.8]
                            [ring "1.4.0"]
                            [com.analogzen.clojure-stack/web-client "0.0.1-SNAPSHOT"]
-                           [http-kit "2.1.18"]]
+                           [http-kit "2.1.18"]
+                           [environ "1.0.2"]]
             :plugins [[lein-modules "0.3.11"]]
 
             :main example.main

+ 3 - 3
web-backend/src/example/core.clj

@@ -9,6 +9,6 @@
 (def app (-> say-hi
              (wrap-resource "public")))
 
-(defn start! []
-      (println "server on.")
-      (run-server app {:port 8080}))
+(defn start! [port]
+      (println "server on. port: " port)
+      (run-server app {:port port}))

+ 11 - 2
web-backend/src/example/main.clj

@@ -1,8 +1,17 @@
 (ns example.main
-    (:require [example.core :as core])
+    (:require [example.core :as core]
+              [environ.core :refer [env]]
+              ;[clojure.tools.cli :refer [parse-opts]]
+      )
     (:gen-class))
 
 ; this file exists as a shim between boot loading and reloadable core code. if the need to AOT goes away, this can too.
 
+(def cli-options [["-p" "--port Port" "Port Number"
+                   :default 3000
+                   :parse-fn #(Integer/parseInt %)]])
+
+
 (defn -main []
-      (core/start!))
+  (let [port (Integer/parseInt (env :port))]
+    (core/start! port)))