diff --git a/deps.edn b/deps.edn index 30b9332..c1467fe 100644 --- a/deps.edn +++ b/deps.edn @@ -3,7 +3,7 @@ :deps {org.clojure/clojure {:mvn/version "1.11.0"} nostromo/nostromo {:git/url "https://github.com/nosana-ci/nostromo" - :sha "66c03f6c0167d6442e0a453721345a6995cf4812"} + :sha "e52e1075a4b5d7b4eab70d0f41b86dc707760c57"} ;; nostromo/nostromo {:local/root "../../../nostromo"} org.clojure/tools.cli {:mvn/version "1.0.214"} diff --git a/src/nosana_node/nosana.clj b/src/nosana_node/nosana.clj index de4b7a9..080bf26 100644 --- a/src/nosana_node/nosana.clj +++ b/src/nosana_node/nosana.clj @@ -648,7 +648,7 @@ Running Nosana Node %s (defn find-next-run "Find all assigned runs and return the first assigned to our -market. Returns a tuple of [run-address run-data]." + market. Returns a tuple of [run-address run-data]." [conf] (let [runs (find-my-runs conf)] (loop [[[run-addr run] & rst] runs] @@ -660,63 +660,81 @@ market. Returns a tuple of [run-address run-data]." (defn work-loop "Main loop." - [conf {:nos/keys [poll-delay exit-chan] :as system}] - (go-loop [active-flow nil - last-health-check (flow/current-time) - healthy? true] - (async/alt! - ;; put anything on :exit-ch to stop the loop - exit-chan (log :info "Work loop exited") - ;; otherwise we will loop onwards with a timeout - (timeout poll-delay) - (cond - (should-check-health? last-health-check) - (let [[status health msgs] (healthy conf)] - (log :info "Checking node health...") - (case status - :success (do - (log :info "Node is healthy") - (recur active-flow (flow/current-time) true)) - :error (do - (log :info (str "Node not healthy, waiting. Status:\n" - (string/join "\n- " msgs))) - (recur nil (flow/current-time) false)))) - - (not healthy?) (do - (log :info "Node not healthy, waiting.") - (recur nil last-health-check false)) - active-flow (do - (log :info "Checking progress of flow " active-flow) - (recur (! work-loop-chan 1) + (recur nil last-health-check true)) + + ;; otherwise we will loop onwards with a timeout + work-loop-chan + (cond + (should-check-health? last-health-check) + (let [[status health msgs] (healthy conf)] + (log :info "Checking node health...") + (case status + :success (do + (log :info "Node is healthy") + (recur active-flow (flow/current-time) true)) + :error (do + (log :info (str "Node not healthy, waiting. Status:\n" + (string/join "\n- " msgs))) + (recur nil (flow/current-time) false)))) + + (not healthy?) (do + (log :info "Node not healthy, waiting.") + (recur nil last-health-check false)) + active-flow (do + (log :info "Checking progress of flow " active-flow) + (recur (!! work-loop-chan :poll) + {:status 200 :body "OK"}) :else {:status 200 :headers {"Content-Type" "text/html"} :body "Not found"}))