Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn start-command-loop
- [{:keys [cmd-ch process] :as prev-state}]
- (if (and cmd-ch process)
- (do (log/warn "already started")
- prev-state)
- (do
- (log/info "starting liquidsoap command loop")
- (let [cmd-ch (async/chan (async/sliding-buffer 1000))
- liq-state (atom {})]
- (future (loop []
- (let [{:keys [cmd data]} (async/<!! cmd-ch)]
- (swap! liq-state #(try
- (case cmd
- :start (if (process-live? %) %
- (start! data))
- :stop (stop-liq! %)
- :quit {})
- (catch Throwable e
- (log/warn e))))
- (when-not (= :quit cmd) (recur))))
- (log/debug "exiting command loop"))
- {:cmd-ch cmd-ch
- :liq-state liq-state}))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement