Skip to content

Instantly share code, notes, and snippets.

@mrcnc
Created August 31, 2017 01:47
Show Gist options
  • Select an option

  • Save mrcnc/29cecf8df73fc585cbb7925a03127243 to your computer and use it in GitHub Desktop.

Select an option

Save mrcnc/29cecf8df73fc585cbb7925a03127243 to your computer and use it in GitHub Desktop.
; follows the workflow outlined here: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
(ns user
(:require [clojure.tools.namespace.repl :refer refresh]
[clojure.tools.logging :as log]
[com.stuartsierra.component :as component]
[com.mydomain.app :as app]))
; define a global var to store the system
(def system nil)
(defn init
"Constructs the current development system."
[]
(alter-var-root #'system
(constantly (app/make-system))))
(defn start
"Starts the current development system."
[]
(log/info "Starting dev system")
(alter-var-root #'system component/start))
(defn stop
"Shuts down and destroys the current development system."
[]
(log/info "Stopping dev system")
(alter-var-root #'system
(fn [s] (when s (component/stop s)))))
(defn go
"Initializes the current development system and starts it running."
[]
(init)
(start))
(defn reset
"Call this method from the REPL to stop the system instance,
reload all the source files that changed, then create an restart
the new system"
[]
(stop)
(refresh :after 'user/go))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment