Created
February 12, 2016 10:11
-
-
Save lbradstreet/41fcd627a46d7c474cd2 to your computer and use it in GitHub Desktop.
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 test-app-docker-metrics.launcher.launch-prod-peers | |
(:gen-class) | |
(:require [aero.core :refer [read-config]] [clojure.core.async :refer [<!! chan]] | |
[test-app-docker-metrics.jobs.sample-submit-job] [onyx.plugin.kafka] [onyx.plugin.sql] | |
[taoensso.timbre :as t] | |
[taoensso.timbre.appenders.3rd-party.rotor :as rotor] | |
[onyx.lifecycle.metrics.metrics] | |
[onyx.lifecycle.metrics.timbre])) | |
(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 (clojure.java.io/resource "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) | |
(Thread. | |
(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