Skip to content

Instantly share code, notes, and snippets.

@raspasov
Last active September 14, 2015 09:09
Show Gist options
  • Save raspasov/6725d9aa2c6d0f628162 to your computer and use it in GitHub Desktop.
Save raspasov/6725d9aa2c6d0f628162 to your computer and use it in GitHub Desktop.
(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