-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move system-configuration stuff to a component (#33)
* Move system-configuration stuff to a component * Cleanup * Handle garbage profiles" * Remove tests since they aren't needed
- Loading branch information
1 parent
8507562
commit 9de3d43
Showing
10 changed files
with
87 additions
and
45 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{:paths ["src" "resources"] | ||
:deps {} | ||
:aliases {:test {:extra-paths ["test"] | ||
:extra-deps {}}}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{:system/env | ||
#profile {:dev :dev | ||
:prod :prod}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns com.vennbilling.system.config | ||
(:require | ||
[aero.core :as aero] | ||
[integrant.core :as ig])) | ||
|
||
|
||
(defmethod aero.core/reader 'ig/ref | ||
[_ _ value] | ||
(ig/ref value)) | ||
|
||
|
||
(defmethod aero.core/reader 'ig/refset | ||
[_ _ value] | ||
(ig/refset value)) | ||
|
||
|
||
(defmethod ig/init-key :system/env [_ env] env) | ||
|
||
|
||
(defn read-config | ||
[config-file opts] | ||
(aero/read-config config-file opts)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(ns com.vennbilling.system.interface | ||
(:require | ||
[com.vennbilling.system.lifecycle :as lifecycle])) | ||
|
||
|
||
(defn start | ||
[banner config-file opts] | ||
(lifecycle/start banner config-file opts)) |
40 changes: 40 additions & 0 deletions
40
components/system/src/com/vennbilling/system/lifecycle.clj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(ns com.vennbilling.system.lifecycle | ||
(:require | ||
[clojure.java.io :as io] | ||
[com.vennbilling.system.config :as c] | ||
[integrant.core :as ig])) | ||
|
||
|
||
(defonce system (atom nil)) | ||
|
||
(def ^:private default-config-file (io/resource "system/default.edn")) | ||
(def ^:private default-opts {:profile :dev}) | ||
|
||
|
||
(defn- valid-profile? | ||
[profile] | ||
(contains? {:prod true | ||
:dev :true} profile)) | ||
|
||
|
||
(defn- stop | ||
[] | ||
(some-> (deref system) (ig/halt!))) | ||
|
||
|
||
(defn start | ||
[banner config-file opts] | ||
|
||
(when banner | ||
(println "\n" banner)) | ||
|
||
(let [f (or config-file default-config-file) | ||
profile (:profile opts) | ||
o (if (valid-profile? profile) | ||
opts | ||
default-opts)] | ||
(->> (c/read-config f o) | ||
(ig/prep) | ||
(ig/init) | ||
(reset! system))) | ||
(.addShutdownHook (Runtime/getRuntime) (Thread. stop))) |
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
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
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