                          ["/add/" :env] #'add-app-env
                          ["/delete/" :env] #'remove-app-env}
                 "/logs" #'load-app-logs
-                "/kill" #'kill-app-instance}}])
+                "/kill" #'kill-app-instances}}])
 
 (defn controller-app [{:keys [params uri] :as req}]
   (if-let [{:keys [handler route-params] :as all} (match-route routes uri)]


(defn load-app-instances [app] (redis! (car/smembers (str app ":instances"))))
(defn add-app-instance [app instance] (redis! (car/sadd (str app ":instances") instance) (notify-routers)))
(defn remove-app-instance [app instance] (redis! (car/srem (str app ":instance") instance) (notify-routers)))

(defn load-hosts [] (redis! (car/smembers :hosts)))
(defn add-host [host] (redis! (car/sadd :hosts host)))

  (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")))
