-
-
Save flosell/a8f0adf5f5fe1b3e61fb5c6adf6fbd93 to your computer and use it in GitHub Desktop.
Code to reproduce flosell/lambdacd#110
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns reproduce-hanging-lambdacd.core | |
(:require | |
[ring.server.standalone :as ring-server] | |
[lambdacd.ui.ui-server :as ui] | |
[lambdacd.runners :as runners] | |
[lambdacd.util :as util] | |
[lambdacd.core :as lambdacd] | |
[clojure.tools.logging :as log] | |
[compojure.core :as compojure] | |
[lambdacd.event-bus :as event-bus] | |
[clojure.core.async :as async] | |
[lambdacd.steps.manualtrigger :as manualtrigger] | |
[lambdacd.steps.control-flow :refer [either in-parallel]] | |
[lambdacd.steps.shell :as shell]) | |
(:gen-class)) | |
(defn printer [ctx] | |
(let [ch (-> (event-bus/subscribe ctx :step-result-updated) | |
(event-bus/only-payload))] | |
(async/go-loop [] | |
(println (str "[PIPELINE " (:nr (:config ctx)) "] " (async/<! ch))) | |
(recur)) | |
ch)) | |
(defn some-step-that-does-nothing [args ctx] | |
{:status :success}) | |
(defn some-step-that-echos-foo [args ctx] | |
(shell/bash ctx "/" "echo foo")) | |
(defn some-step-that-echos-bar [args ctx] | |
(shell/bash ctx "/" "echo bar")) | |
(defn some-failing-step [args ctx] | |
(shell/bash ctx "/" "echo \"i am going to fail now...\"" "exit 1")) | |
(def pipeline-def | |
`((either | |
manualtrigger/wait-for-manual-trigger | |
) | |
some-step-that-does-nothing | |
(in-parallel | |
some-step-that-echos-foo | |
some-step-that-echos-bar) | |
manualtrigger/wait-for-manual-trigger | |
some-failing-step)) | |
(defn mk-pipeline [nr] | |
(let [config {:home-dir (util/create-temp-dir) | |
:name (str "reproduce hanging lambdacd " nr) | |
:nr nr} | |
;; initialize and wire everything together | |
pipeline (lambdacd/assemble-pipeline pipeline-def config) | |
app (ui/ui-for pipeline)] | |
(printer (:context pipeline)) | |
(runners/start-one-run-after-another pipeline) | |
(log/info "started pipeline" nr) | |
(compojure/context (str "/" nr) [] app))) | |
(defn -main [& args] | |
(let [uis (map mk-pipeline (range 100)) | |
app (apply compojure/routes uis)] | |
(ring-server/serve app {:open-browser? false | |
:port 8080}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject reproduce-hanging-lambdacd "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:dependencies [[lambdacd "0.9.0"] | |
[lambdacd-value-stream "0.1.0"] | |
[lambdacd-git "0.1.2"] | |
[lambdacd-cron "0.1.1"] | |
[ring-server "0.3.1"] | |
[org.clojure/clojure "1.7.0"] | |
[org.clojure/tools.logging "0.3.0"] | |
[org.slf4j/slf4j-api "1.7.5"] | |
[ch.qos.logback/logback-core "1.0.13"] | |
[ch.qos.logback/logback-classic "1.0.13"]] | |
:profiles {:uberjar {:aot :all}} | |
:main reproduce-hanging-lambdacd.core) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment