Create a gist now

Instantly share code, notes, and snippets.

componentフレームワークを利用したシステムの起動・停止・リロード関数
(ns user
(:require [com.stuartsierra.component :as component]
[clojure.tools.namespace.repl :refer (refresh)]
[example-component-ring.component :as app]))
(def system nil)
;; システム初期化
(defn init []
(alter-var-root #'system
(constantly (app/create-system {:port 3000}))))
;; システム起動
(defn start []
(alter-var-root #'system component/start))
;; システム停止
(defn stop []
(alter-var-root #'system
(fn [s] (when s (component/stop s)))))
;; 初期化&起動
(defn go []
(init)
(start))
;; システムリロード
(defn reset []
(stop)
(refresh :after 'user/go))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment