-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem.clj
37 lines (30 loc) · 797 Bytes
/
system.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(ns city-weather-clj.system
(:require [city-weather-clj.system.config]
[clojure.java.io :as io]
[integrant.core :as ig]
[aero.core :as aero]))
(defmethod aero/reader 'ig/ref
[_ _ value]
(ig/ref value))
(defmethod aero/reader 'io/resource
[_ _ value]
(try
(slurp (io/resource value))
(catch Exception _
(println "Couldn't read resource \"" value \"))))
(defn read-classpath-config
[file-name]
(aero/read-config (io/resource file-name)))
(comment
(read-classpath-config "system-config.edn"))
(defonce state (atom nil))
(defn start!
[config-file]
(let [config (read-classpath-config config-file)]
(reset!
state
(-> (ig/prep config)
(ig/init)))))
(defn stop!
[]
(reset! state (ig/halt! @state)))