(ns backend.boot
  {:boot/export-tasks true}
  (:require [boot.core :refer :all]
            [reloaded.repl :refer [go]]
            [backend.main :refer :all]))

(deftask start-app
  [p port   PORT int  "Port"
   r reload      bool "Add reload mw"]
  (let [f (delay
            (setup-app! {:port port
                        :reload reload
                        :reload-dirs (get-env :directories)})
            (go))]
    (with-post-wrap fileset @f fileset)))

(ns backend.boot
  {:boot/export-tasks true}
  (:require [boot.core :refer :all]
            [reloaded.repl :refer [go]]
            [backend.main :refer :all]))

(deftask start-app
  [p port   PORT int  "Port"
   r reload      bool "Add reload mw"]
  (let [x (atom nil)]
    (with-post-wrap fileset
      (swap! x (fn [x]
                  (if x
                    x
                    (do (setup-app! {:port port
                                     :reload reload
                                     :reload-dirs (get-env :directories)})
                        (go)))))
      fileset)))

Make start-app behave better if system start fails
Make start-app behave better if system start fails

If `go` threw an exception delay would cache the exception and throw the same one for each subsequent call. Instead we want to execute go until it succeeds. This way user can fix the error causing problems in REPL.
Deraen/saapas