-
Notifications
You must be signed in to change notification settings - Fork 58
Manual trigger doesn't work sometimes (with ring-reload) #153
Comments
Hmm, if I understand you correctly, you are using lein-rings auto-reload, keeping the process running and reloading changed source-files on the fly. I actually never tried this but I can imagine things don't just work out of the box in this case. It's an interesting feature though so if you share some sample code that reproduces the issue I'd be happy to play around with it, see if there's something we can do about it. |
(def sb
`(
(alias "Triggers"
(either
(steps/wait-for-git sb-repo sb-refs)
manualtrigger/wait-for-manual-trigger))
(alias "Test and build"
(with-workspace
(steps/clone sb-repo)
git/list-changes
steps/lein-test))
(alias "Deploy"
steps/info)
#_(alias "Post-deploy"
steps/slack)
)) But from what i saw it happens with whatever pipeline. Especially when change pipeline code, but maybe also steps. Not really sure, because on the end i have to restart the app all the time to be sure it is actual. It happens all the time. |
Could you provide the whole project? I'm interested in how LambdaCD is configured and initialized and how lein-ring is configured |
(defproject sb-pipeline "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[lambdacd "0.12.1"]
[ring-server "0.4.0"]
[org.clojure/clojure "1.8.0"]
[org.clojure/tools.logging "0.3.1"]
[org.slf4j/slf4j-api "1.7.22"]
[ch.qos.logback/logback-core "1.1.8"]
[ch.qos.logback/logback-classic "1.1.8"]
[lambdacd-git "0.2.0"]
[http-kit "2.2.0"]
[cheshire "5.7.0"]]
:profiles {:uberjar {:aot :all}}
:plugins [[lein-ring "0.9.7"]]
:ring {:handler sb-pipeline.core/app
:init sb-pipeline.core/start-pipelines}
:main sb-pipeline.core) (ns sb-pipeline.core
(:require [sb-pipeline.pipeline :as pipeline]
[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]
[ring.util.response :refer [response not-found]]
[lambdacd.event-bus :as event-bus]
[lambdacd-git.core :as git]
[clojure.core.async :as async]
[sb-pipeline.slack :as slack])
(:gen-class))
(defn failure-notifications [ctx]
(let [subscription (event-bus/subscribe ctx :step-finished)
steps-finished (event-bus/only-payload subscription)]
(async/go-loop []
(let [event (async/<! steps-finished)]
(when (= :failure (get-in event [:final-result :status]))
(slack/send-message event)))
(recur))))
(def pipelines
{:sb (lambdacd/assemble-pipeline pipeline/sb {:home-dir "builds/sb"
:name "hidden"
:max-builds 3
:ui-config {:expand-active-default true
:expand-failures-default true}})})
(def routes (compojure/routes
(compojure/context "/sb" [] (ui/ui-for (:sb pipelines)))))
(def app routes)
(defn start-pipelines []
(git/init-ssh!)
(runners/start-one-run-after-another (:sb pipelines))
;(failure-notifications (:context (:sb pipelines)))
)
(defn -main [& args]
(start-pipelines)
(ring-server/serve app {:open-browser? true
:port 8080})) For now it looks like that. Please let me know if this is what you want or should i push on github whole project for a while. |
Thanks, looks good, I hope I’ll have some time to play around with it over the weekend. |
I now had some time today playing with this and I think I figured out what happens there: You might a couple of questions here:
With this in mind, we need to do a few things to get this right:
Here is my approach to make this happen:
You'll find the full, working example here. Mostly a normal LambdaCD project, the reloading-part is in |
Also added a reference to the example in the wiki. |
I refactored your solution with /~https://github.com/tolitius/mount. What do you think about it? (defn start-pipelines [pipelines]
(doseq [pipeline (vals pipelines)]
(runners/start-one-run-after-another pipeline)))
(defn stop-pipelines [pipelines]
(doseq [pipeline (vals pipelines)]
(when-let [old-ctx (:context pipeline)]
((get-in old-ctx [:config :shutdown-sequence]) old-ctx))))
(mount/defstate init
:start (git/init-ssh!))
(mount/defstate pipelines
:start {:sb (lambdacd/assemble-pipeline pipeline/sb {:home-dir "builds/sb"
:name "Foo"
:max-builds 3
:ui-config {:expand-active-default true
:expand-failures-default true}})}
:stop (stop-pipelines pipelines))
(mount/defstate routes
:start (compojure/routes
(compojure/context "/sb" [] (ui/ui-for (:sb pipelines)))))
(mount/defstate pipelines-run
:start (start-pipelines pipelines))
(defn start []
(mount/start))
(defn -main [& args]
(start)
(httpkit/run-server routes {:port 8080})) In that way project.clj (defproject sb-pipeline "0.1.0-SNAPSHOT"
...
:dependencies [
...
[mount "0.1.11"]]
:plugins [[lein-ring "0.9.7"]]
:ring {:handler sb-pipeline.core/routes
:init sb-pipeline.core/start}) |
Interesting, I like it! Could you publish the full project somewhere as an example for others? Either as its own repository or as a PR in the existing example project? I'm sure lots of people are interested in having a clean solution for this. |
I will be glad to do it. After put project on production (this week?) i will share what i did. But maybe i can share solution for only |
The above example with |
Thanks for the feedback! I updated the README in |
not active |
I am testing lambda cd with
lein ring server
and a lot of time i see this message after click on manual trigger to run and nothing is happening. I have to turn down everything and run again. Then new build is set by default after start the app and works.Edit:
Probably each time when i change pipeline. How to deal with it to not restart app all the time?
The text was updated successfully, but these errors were encountered: