   should-trigger-next-build?
   (every-pred is-first-step? is-not-retriggered?))
 
-(defmacro while-not-stopped [ctx & body]
+(defmacro while-not-stopped
+  "Execute a runners body until it is stopped from the outside (usually by someone calling `stop-runner`, e.g. on shutdown)."
+  [ctx & body]
   `(let [running# (atom true)]
      (async/go
        (async/<! (event-bus/subscribe ~ctx :stop-runner))

        (async/<!! first-steps-finisehd)))))

(defn start-one-run-after-another
  "Runner that always keeps one pipeline-run active. It waits for a run to complete, then starts a new one."
  [{pipeline-def :pipeline-def context :context}]
 (async/thread
   (while-not-stopped context
     (execution/run-pipeline pipeline-def context))))

(defn stop-runner [ctx]
  (log/info "Stopping runner...")
  (event-bus/publish!! ctx :stop-runner {}))

     (log/info "Runner stopped. No new pipeline instances will be spawned.")))

(defn start-new-run-after-first-step-finished
  "Runner that makes sure there is always one pipeline-run with the first step active. Useful if the first step is waiting for
  a trigger such as a VCS commit and you don't want to wait for the whole pipeline to complete before starting the next run.
  Do not use this if your first step finishes immediately as this will lead to lots of active pipelines"
  [{pipeline-def :pipeline-def context :context}]
