Skip to content

Commit

Permalink
Read server port from config
Browse files Browse the repository at this point in the history
Summary: Set default server port in base config and use that if not set elsewhere.

Test Plan:
  lein test

Reviewers: #standard_treasury, keith

Reviewed By: #standard_treasury, keith

Differential Revision: http://phabricator.corp.standardtreasury.com/D3780
  • Loading branch information
jimbru committed Nov 13, 2014
1 parent 90d0e7b commit b6fbaea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions resources/conf/base.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
:port 5000
}
2 changes: 1 addition & 1 deletion src/clams/app.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
(when (nil? @server)
(conf/load!)
(let [middleware (:middleware opts)
port (get opts :port 5000)]
port (conf/get :port)]
(reset! server (httpkit/run-server (app app-ns middleware) {:port port}))))))

(defn stop-server
Expand Down
3 changes: 2 additions & 1 deletion src/clams/conf.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

(defn load!
[]
(reset! full-conf (merge (read-config "default")
(reset! full-conf (merge (read-config "base")
(read-config "default")
(read-env))))

(defn unload!
Expand Down
4 changes: 4 additions & 0 deletions test/clams/test/conf_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@
(is (= (conf/get :database-url) "sql://dev.fake:1234/foobar"))
(is (= (conf/get-all) {:database-url "sql://dev.fake:1234/foobar"
:log-level :debug})))

(deftest base-test
(conf/load!)
(is (= (conf/get :port) 5000)))

0 comments on commit b6fbaea

Please sign in to comment.