leiningen

N.B. The maintainers are on #leiningen on Libera chat IRC. Go there for direct support/bug reports.
2020-05-22T16:47:41.142700Z

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"]}

2020-05-22T16:48:06.143Z

Any tips how to debug this or what could be causing the problem?

2020-05-22T16:52:10.143400Z

It seems to be caused by calling this code:

(s/schedule #(reset! metrics (compute-metrics))
            {:id    "recompute-metrics"
             :in    [15 :seconds]
             :every [15 :minutes]})

2020-05-22T17:17:15.144500Z

@pavel.klavik if you use Control-\ or jstack <PID> or kill with signal 3 you'll get a trace of all running threads

2020-05-22T17:17:31.144900Z

one of them will be doing something "suspicious" most of the time, and usually it's the longest trace

2020-05-22T17:19:11.145700Z

@pavel.klavik also - I would expect that call (at the top level or inside def) to be a problem

2020-05-22T17:19:41.146400Z

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

2020-05-22T17:20:12.147Z

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

2020-05-22T17:23:57.147400Z

thx, makes sense, I moved into a function called from main and it works now

2020-05-22T17:24:35.147700Z

why does this work with lein run?

2020-05-22T17:26:05.148400Z

usually because when you use lein run you want the process to stay running until you explicitly shut it down

2020-05-22T17:26:46.149100Z

the hanging during compile is literally just the server running, meaning the vm doesn't shut down

2020-05-22T17:27:45.150Z

it's sitting around waiting to do its task in 15 minutes

2020-05-22T17:28:30.150300Z

I see, thx for the explanation