Fork me on GitHub
#component
<
2016-05-12
>
keeth16:05:27

@mss i do something like this in my clojure services to await shutdown (i call it from main):

(defn await-termination []
  (let [termination-channel (async/chan)]
    (.addShutdownHook (Runtime/getRuntime)
                      (Thread. #(do
                                 (log/info "received shutdown signal")
                                 (async/close! termination-channel))))
    (async/<!! termination-channel)))

mss16:05:39

interesting. in that case you’re blocking whatever thread you invoke await-termination on, no? I had wanted to avoid that behavior if possible

keeth23:05:26

ya i have a worker service that is just a bunch of async loops. so i block the main thread.