                                 :user-id user-id
                                 :tracking-id tracking-id}))
 
-(defn stop-tracking! [user-id]
+(defn stop-tracking! [tracking user-id]
   (swap! tracking
          (fn [tr]
            (if-let [manager (tr user-id)]

(defrecord HttpServer [peer-config]
  component/Lifecycle
  (start [{:keys [sente] :as component}]

    ; Just reset atoms for now. Atoms should be created and reset in here
    (reset! tracking {})
    (reset! deployments {})

    (println "Starting HTTP Server")

    (defroutes my-routes
      (GET  "/" [] (page))
      (GET  "/chsk" req ((:ring-ajax-get-or-ws-handshake sente) req))
      (POST "/chsk" req ((:ring-ajax-post sente) req))

      (resources "/react" {:root "react"})
      (route/not-found "Page not found"))

    (let [deployments (atom {})
          tracking (atom {})
          event-handler-fut (start-event-handler sente peer-config deployments tracking)
          ; TODO: no way to currently stop this watch
          _ (refresh-deployments-watch (partial send-mult-fn 
                                                (:chsk-send! sente) 
                                                (:connected-uids sente)) 
                                       (zk/connect (:zookeeper/address peer-config))
                                       deployments)
          handler (ring.middleware.defaults/wrap-defaults routes ring-defaults-config)
          server (http-kit-server/run-server handler {:port 3000})
          uri (format "http://localhost:%s/" (:local-port (meta server)))]
      (println "Http-kit server is running at" uri)
      (assoc component 
             :server server 
             :event-handler-fut event-handler-fut 
             :deployments deployments 
             :tracking tracking)))
  (stop [{:keys [server tracking deployments] :as component}]
    (println "Stopping HTTP Server")
    (stop-all-tracking! tracking)
    (future-cancel (:event-handler-fut component))
    (server :timeout 100)
    (assoc component :server nil :event-handler-fut nil :deployments nil :tracking nil)))

(defn new-http-server [peer-config]
  (map->HttpServer {:peer-config peer-config}))
