Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(ns test-app-docker-metrics.launcher.launch-prod-peers
(:require [aero.core :refer [read-config]] [clojure.core.async :refer [<!! chan]]
[] [onyx.plugin.kafka] [onyx.plugin.sql]
[taoensso.timbre :as t]
[taoensso.timbre.appenders.3rd-party.rotor :as rotor]
(defn standard-out-logger
"Logger to output on std-out, for use with docker-compose" [data]
(let [{:keys [output-fn]} data]
(println (output-fn data))))
(defn -main [n & args]
(let [n-peers (Integer/parseInt n)
config (read-config ( "config.edn") {:profile :default})
peer-config (-> (:peer-config config)
(assoc :onyx.log/config {:appenders
{:standard-out {:enabled? true
:async? false
:output-fn t/default-output-fn
:fn standard-out-logger}
:rotor (-> (rotor/rotor-appender
{:path "onyx.log"
:max-size (* 512 102400)
:backlog 5})
(assoc :min-level :info))}}))
peer-group (onyx.api/start-peer-group peer-config)
env (onyx.api/start-env (:env-config config))
peers (onyx.api/start-peers n-peers peer-group)]
(println "Attempting to connect to Zookeeper @" (:zookeeper/address peer-config))
(.addShutdownHook (Runtime/getRuntime)
(fn []
(doseq [v-peer peers]
(onyx.api/shutdown-peer v-peer))
(onyx.api/shutdown-peer-group peer-group)
(shutdown-agents)))) (println "Started peers. Blocking forever.")
;; Block forever.
(<!! (chan))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment