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.core.async :refer [>!! <!! >! <! go-loop alt! timeout]]
[clojure.tools.namespace.repl :as tn] [clojure.tools.namespace.repl :as tn]
[mount :as app] [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 [] (defn start []
(app/start)) (app/start)
:started)
(defn stop [] (defn stop []
(app/stop)) (app/stop)
:stopped)
(defn refresh [] (defn refresh []
(stop) (stop)

View file

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