Hi, after adding [org.immutant/scheduling "2.1.10"]
dependency, lein run works fine but lein uberjar gets stuck on lein compile prep-task forever, no output or errors:
:uberjar {:source-paths ["env/prod/clj"]
:omit-source true
:main orgpad.server.core
:aot [orgpad.server.core]
:uberjar-name "orgpad.jar"
:prep-tasks ["clean"
["run" "-m" "orgpad.build/release"]
"compile"
["garden" "once"]]
:resource-paths ["env/prod/resources"]}
Any tips how to debug this or what could be causing the problem?
It seems to be caused by calling this code:
(s/schedule #(reset! metrics (compute-metrics))
{:id "recompute-metrics"
:in [15 :seconds]
:every [15 :minutes]})
@pavel.klavik if you use Control-\
or jstack <PID>
or kill
with signal 3 you'll get a trace of all running threads
one of them will be doing something "suspicious" most of the time, and usually it's the longest trace
@pavel.klavik also - I would expect that call (at the top level or inside def) to be a problem
clojure doesn't have a "compile mode", when you compile a file, all top level forms are run, and if they have side effects those side effects happen right then
the typical fix here is to have a function that calls s/schedule and invoke it from main, or use a delay or component config to arrange for it to run later as needed
thx, makes sense, I moved into a function called from main and it works now
why does this work with lein run?
usually because when you use lein run you want the process to stay running until you explicitly shut it down
the hanging during compile is literally just the server running, meaning the vm doesn't shut down
it's sitting around waiting to do its task in 15 minutes
I see, thx for the explanation