 (defmethod user-msg :default [msg]
   (infof "ERROR: unknown user message %s" msg)
   #_(srv/send-msg
-   (msg :ws) {:op "error" :payload "ERROR: unknown user message"}))
-
-
-
-
-;;; ------------------------------------------------------------------------;;;
-;;;                Control  starting and stoping Webserver                  ;;;
-;;; ------------------------------------------------------------------------;;;
+     (msg :ws) {:op "error" :payload "ERROR: unknown user message"}))
+
+(defmethod user-msg :run [msg]
+  (let [info (msg :payload)
+        ws (info :ws)
+        eid (info "eid")
+        eid (if (str/ends-with? eid "/") (austr/butlast 1 eid) eid)
+        eid (if (str/starts-with? eid "/") (austr/drop 1 eid) eid)]
+    (infof "RUN: %s" info)
+    (srv/send-msg ws {:op :validate :payload (va/validate-exp eid)})
+    (srv/send-msg ws {:op :stop :payload {}} :noenvelope true)))
 
 (defn msg-handler [msg]
-  (infof ":MSG-HANDLER :MSG %s" msg)
-  (let [{:keys [op data]} (msg :data)]
+  (let [{:keys [ws data]} msg
+        {:keys [op data]} data]
+    (infof "MSG-HANDLER: MSG %s" (msg :data))
     (case op
+      (:done "done")
+      (do (infof "WS: %s, sending stop msg" ws)
+          (srv/send-msg ws {:op :stop :payload {}} :noenvelope true))
       ;;null for now
-      (user-msg (msg :data)))))
+      (user-msg {:op op :payload (assoc data :ws ws)}))))
 
 
 (defn on-open [ch op payload]

         [:p (str "Params" params)]
         [:hr]
         [:p (str "User Agent: " user-agent)])))))



(defn start-server
  [port]
  (let [ch (srv/start-server port :main-handler aerobio-handler)]
    (infof "Server start, reading msgs from %s" ch)
    (update-adb :chan ch
                :idfn [(partial gensym "aerobio-")]
                :connfn [identity])
    (go-loop [msg (<! ch)]
      (let [{:keys [op payload]} msg]
        (future (server-dispatch ch op payload))
        (when (not= op :stop)
          (recur (<! ch)))))))

(defn stop-server []
  (async/>!! (get-adb :chan) {:op :stop :payload {:cause :userstop}}))


(defn start! [port]
  (timbre/set-level! :info) ; :debug
  (start-tool-watcher)
  (start-job-watcher)
  (start-server port))

(defn stop! []
  (stop-tool-watcher)
  (stop-job-watcher)
  (stop-server))


        data (connfn {:uid uid})
        name-uuids (or (get-adb uid-name) [])]
    (infof ":SRV :open %s" uid)
    (update-adb :ws ws
                [ws :uuid] uuid
                [uuid :ws] ws, [uuid :name] uid-name
                [uuid :rcvcnt] 0, [uuid :sntcnt] 0
                uid-name (conj name-uuids uuid))
    (srv/send-msg ws {:op :register :payload data})))


(defn server-dispatch [ch op payload]
