Skip to content

Instantly share code, notes, and snippets.

@srid
Created October 11, 2011 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srid/1279714 to your computer and use it in GitHub Desktop.
Save srid/1279714 to your computer and use it in GitHub Desktop.
(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)))))))
@srid
Copy link
Author

srid commented Oct 11, 2011

(defonce ^{:private true} running-components (agent {}))
(defn- update-running-components
  "Update the running components in the cloud"
  [agt]
  (let [comps (cloud/components-logs cloud/sandbox)]
    (reduce (fn [newagt comp]
              (if (newagt comp)
                newagt
                (assoc newagt comp (register-log-source (comps comp)))))
            newagt
            (keys comps))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment