               :body (json/write-str start-options)})
     id))
 
-(defn init-routing-table []
-  (doseq [app (load-apps)]
-    (swap! router assoc-in [:instances app] (load-app-instances app))))
-
 (defn load-ports-in-use [host]
   (set (mapv #(:PublicPort (first (:Ports %))) (get-containers host))))
 

  (when-let [id (:Id (load-container-by-host-and-port host port))]
    (stop-container host id)))

(defn health-check-host [host port]
  (mark-host-health (str host ":" port)
   (loop [n 15]
     (when (pos? n)
       (if (= 200 (:status @(http/get (str "http://" host ":" port "/") {:timeout 5000})))
         true
         (do
           (Thread/sleep (* (- 15 n) 500))
           (recur (dec n))))))))

(defn health-check-instances []
  (doseq [l (vals (:instances @router))]
    (doseq [i l]
      (let [[host port] (ssplit i)]
        (health-check-host host port)))))

(defn pull-docker-image [host image]
  (let [[image tag] (ssplit image)]


(defn extract-app [req] (first (ssplit ((:headers req) "host"))))

(defn app [req] (controller-app req))

(defn init [] (get-token))

