Created
October 11, 2011 22:49
-
-
Save srid/1279714 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
(defonce ^{:private true} running-hosts (agent {})) | |
(defn- update-running-hosts | |
"Update the running-hosts agent with new set of hosts from AWS" | |
[curr] | |
(let [hosts (clojure.string/split-lines | |
(run "scripts/print-running-hosts"))] | |
(loop [newhosts (remove curr hosts) | |
nxt curr] | |
(if (empty? newhosts) | |
nxt | |
(let [host (first newhosts) | |
tailer (register-log-source host (server-log-tail-f host))] | |
(println "Added new host: " host) | |
(recur (next newhosts) | |
(assoc nxt host tailer))))))) |
Author
srid
commented
Oct 11, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment