Skip to content

Instantly share code, notes, and snippets.

@hikoz
Created February 9, 2015 07:21
Show Gist options
  • Save hikoz/035ab60d8cfef802ea69 to your computer and use it in GitHub Desktop.
Save hikoz/035ab60d8cfef802ea69 to your computer and use it in GitHub Desktop.
boot template
# boot foo.boot usage sleep -t 10
(set-env!
:dependencies '[[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[org.clojure/tools.logging "0.3.1"]
[org.slf4j/slf4j-simple "1.7.10"]])
(doseq [s '(info warn)] (ns-unmap *ns* s))
(require '[clojure.core.async :as async
:refer (go go-loop chan <! >! <!! >!! timeout thread)]
'[clojure.tools.logging :refer (debug info warn error spy)])
(defmacro logconf [& pairs]
`(do
~@(for [[k v] (partition 2 pairs)]
`(System/setProperty (. org.slf4j.impl.SimpleLogger ~k) ~v))))
(logconf LOG_FILE_KEY "System.out"
DEFAULT_LOG_LEVEL_KEY "TRACE"
SHOW_DATE_TIME_KEY "true"
DATE_TIME_FORMAT_KEY "yyyy-MM-dd'T'HH:mm:ss.SSS")
(defn dump-usage []
(thread (let [rt (Runtime/getRuntime)]
(loop [] (<!! (timeout 5000))
(debug (/ (- (.totalMemory rt)
(.freeMemory rt))
1024.0 1024) :MBused)
(recur)))))
(deftask usage []
(dump-usage))
(deftask sleep
[t sleep-sec VAL int "sleep time"]
(info :start)
(<!! (timeout (* (or (:sleep-sec *opts*) 10)
1000)))
(info :end))
(defn -main [& args]
(eval `(boot.core/boot ~@args)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment