       (resources "/")
       (resources "/react" {:root "react"})
       (route/not-found "Page not found"))
-    (start-event-handler sente peer-config)
-    (refresh-deployments-watch (partial send-mult-fn 
-                                        (:chsk-send! sente) 
-                                        (:connected-uids sente)) 
-                               (zk/connect (:zookeeper/address peer-config)))
-
-    (let [my-ring-handler (ring.middleware.defaults/wrap-defaults my-routes ring-defaults-config)
+    
+    (let [event-handler-fut (start-event-handler sente peer-config)
+          ; 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)))
+          my-ring-handler (ring.middleware.defaults/wrap-defaults my-routes ring-defaults-config)
           server (http-kit-server/run-server my-ring-handler {:port 3000})
           uri (format "http://localhost:%s/" (:local-port (meta server)))]
       (println "Http-kit server is running at" uri)
-      (assoc component :server server)))
+      (assoc component :server server :event-handler-fut event-handler-fut)))
   (stop [{:keys [server] :as component}]
     (println "Stopping HTTP Server")
+    (stop-all-tracking!)
+    (future-cancel (:event-handler-fut component))
     (server :timeout 100)
-    (assoc component :server nil)))
+    (assoc component :server nil :event-handler-fut nil)))
 
 (defn new-http-server [peer-config]
   (map->HttpServer {:peer-config peer-config}))

       (map (fn [[child stat]]
              (vector child
                      {:created-at (java.util.Date. (:ctime stat))
                       :modified (java.util.Date. (:mtime stat))})))
       (into {})
       (reset! deployments)
       (distribute-deployments send-all-fn!)))

            [:security :anti-forgery]
            {:read-token (fn [req] (-> req :params :csrf-token))}))

(def deployments (atom {}))
(def tracking (atom {}))

;(deref tracking)

; Improve fn name
(defn job-peer-allocated-task [job-allocations job-id peer-id]
  (ffirst 
