Last active
September 14, 2015 09:09
-
-
Save raspasov/6725d9aa2c6d0f628162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cloud-monkey.env | |
(:require [environ.core :as environ])) | |
(defonce env environ/env) | |
(defn merge-with-env! [a-map] | |
(alter-var-root #'env (fn [x] (merge x a-map)))) | |
... then in core.clj | |
(defn -main | |
"Monkey run cloud, from Clojure" | |
[& args] | |
;always use original config first | |
;try to load from OS config | |
(let [config-original (try (slurp "/etc/cloud-monkey/config-original.clj") | |
(catch Exception e e)) | |
;if not available, try to load from resources | |
config-original (if (instance? Exception config-original) | |
(slurp (jio/resource "etc/cloudmonkey/config-original.clj")) | |
config-original)] | |
(env/merge-with-env! (read-string config-original)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment