start/stop selected states

useful for debugging, REPLing, testing
This commit is contained in:
anatoly 2015-10-25 22:08:37 -04:00
parent bba76ff0a5
commit 1be280a478
2 changed files with 14 additions and 10 deletions

View file

@ -14,13 +14,15 @@
;; [clojure.core.async :refer [>!! <!! >! <! go-loop alt! timeout]]
[clojure.tools.namespace.repl :as tn]
[mount :as app]
[app :refer :all])) ;; <<<< replace this your "app" namespace(s) you want to be available at REPL time
[app :refer [create-nyse-schema find-orders add-order]])) ;; <<<< replace this your "app" namespace(s) you want to be available at REPL time
(defn start []
(app/start))
(app/start)
:started)
(defn stop []
(app/stop))
(app/stop)
:stopped)
(defn refresh []
(stop)

View file

@ -56,7 +56,7 @@
(throw (RuntimeException. (str "could not stop [" name "] due to") t)))))
(alter-meta! var assoc :started? false)))
(defn find-states []
(defn find-all-states []
(->> (all-ns)
(mapcat ns-interns)
(map second)
@ -75,10 +75,12 @@
(sort-by (comp :order meta) order)
(map #(fun % (meta %)))))
(defn start []
(defn start [& states]
(let [states (or states (find-all-states))]
(doall
(bring (find-states) up <)))
(bring states up <))))
(defn stop []
(defn stop [& states]
(let [states (or states (find-all-states))]
(doall
(bring (find-states) down >)))
(bring states down >))))