   (.. listener socket getLocalPort))
 
 (defn update-listener [listener config]
-  (if-let [req-addr (log/spy (get-in config [:config :listen-address]))]
+  (when-let [l (keyword (get-in config [:config :log-level]))]
+    (when-not (= l (:level log/*config*))
+      (log/info (str "Setting log level to " l))
+      (log/set-level! (keyword l))))
+  (if-let [req-addr (log/spy :trace (get-in config [:config :listen-address]))]
     (let [req-port (:port (parse-address req-addr))
           old-port (and listener (get-port listener))]
       (if (and listener
                (= old-port req-port))
-        (log/spy listener)
+        (log/spy :trace listener)
         (let [new-l (ServerSocketChannel/open)]
           (and listener (.close listener))
-          (doto (log/spy new-l)
+          (doto (log/spy :trace new-l)
             (.configureBlocking false)
             (.bind (InetSocketAddress. req-port))))))
     nil))

            [clojure.test :as test :refer [deftest testing is]]
            [clojure.java.io :as io]
            [clojure.set :as set]
            [taoensso.timbre :as log :refer [debug]]
            [clojure.core.async :as async
             :refer [<! <!! go chan >! close! alts!]]))


            ))))))



(defn backend-chan
  [host port listener]
  (info (str "started backend for " host ":" port))
  (let [ch (chan)]
    (future
      (backend listener host port ch)
      (info (str "backend " host  ":" port " quit")))
    ch))

(defn parse-address [a]
