     (println "Checking host health")
     (if-not (health-check-host host port)
       (do
-        ;(stop-container host id)
+        (stop-container host id)
         (throw (Exception. "Failed to deploy new instance.")))
       (try
         (println "Adding" (str host ":" port) "to router")

                         ["/add/" :env] #'add-app-env
                         ["/delete/" :env] #'remove-app-env}
                "/logs" #'load-app-logs
                "/kill" #'kill-app-instance}}])

(defn controller-app [{:keys [params uri] :as req}]
  (if-let [{:keys [handler route-params] :as all} (match-route routes uri)]

  (rand-nth (vec (clojure.set/difference port-range (load-ports-in-use host)))))

(defn load-container-by-host-and-port [host port]
  (first (filter #(= port (str (:PublicPort (first (:Ports %))))) (get-containers host))))

(defn stop-container [host id]
  (docker! :post host (str "containers/" id "/stop")))
