Created
August 17, 2014 20:25
-
-
Save matstani/4852df3eb4856bccbce4 to your computer and use it in GitHub Desktop.
componentフレームワークを利用したシステムの起動・停止・リロード関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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