Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools.build does not exit when requiring the Clay API #98

Open
daslu opened this issue Apr 26, 2024 · 4 comments
Open

tools.build does not exit when requiring the Clay API #98

daslu opened this issue Apr 26, 2024 · 4 comments

Comments

@daslu
Copy link
Member

daslu commented Apr 26, 2024

Reported by jason1903 on Slack:
https://clojurians.slack.com/archives/C0BQDEJ8M/p1714087040436159

deps.edn:

{:deps {org.clojure/clojure {:mvn/version "1.12.1"} }
 :aliases {:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}
                          slipset/deps-deploy {:mvn/version "0.2.1"}
                          org.scicloj/clay {:mvn/version "2-beta8"}}
                   :ns-default build}}}

build.clj:

(ns build
  (:require
    [scicloj.clay.v2.api :as clay]))

(defn hello
  [_opts]
  (println "hello"))

Then

clojure -T:build hello

never exits.

@daslu
Copy link
Member Author

daslu commented Apr 26, 2024

The problem is that Clay starts a portal session to receive its client-side code.
That session should be stopped afterwards -- we will fix this in a future version.

For now, here is a workaround:

(defn hello
  [_opts]
  (println "hello")
  (portal.api/close))

(Edit: had a typo in this code earlier, missed the important part.)

@holyjak
Copy link
Member

holyjak commented Jul 31, 2024

A possibly way to prevent this would be on Portal side - either add a shutdown hook that stops the server (not 100% sure this works) or get http kit updated so that clients could request the "server-loop" thread org.httpkit.server.HttpServer#serverThread be a daemon thread, which does not prevent JVM from stopping.

@holyjak
Copy link
Member

holyjak commented Jul 31, 2024

@daslu your suggestion did not work for me - the http-kit server kept running. I had to call (portal.runtime.jvm.launcher/stop).

holyjak added a commit to scicloj/wolframite that referenced this issue Jul 31, 2024
Issue: When we require Clay, it starts a Portal server process - which keeps running and prevents the JVM from exiting.

Fix: Only require Clay for build-site, and stop portal manually

See scicloj/clay#98
holyjak added a commit to scicloj/wolframite that referenced this issue Jul 31, 2024
Issue: When we require Clay, it starts a Portal server process - which keeps running and prevents the JVM from exiting.

Fix: Only require Clay for build-site, and stop portal manually

See scicloj/clay#98
@daslu
Copy link
Member Author

daslu commented Jul 31, 2024

Interesting.

Thanks for checking and discovering that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants