This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-24
Channels
- # announcements (4)
- # asami (5)
- # babashka (20)
- # beginners (94)
- # bristol-clojurians (1)
- # calva (23)
- # cider (2)
- # clj-commons (3)
- # clj-kondo (43)
- # cljfx (2)
- # cljs-dev (13)
- # clojure (112)
- # clojure-dev (44)
- # clojure-europe (17)
- # clojure-nl (5)
- # clojure-poland (12)
- # clojure-spec (2)
- # clojure-uk (3)
- # clojurebridge (1)
- # clojurescript (92)
- # cursive (17)
- # data-science (8)
- # datahike (1)
- # datalevin (1)
- # datomic (3)
- # deps-new (7)
- # events (2)
- # fulcro (40)
- # graalvm (110)
- # holy-lambda (16)
- # introduce-yourself (1)
- # lsp (13)
- # malli (8)
- # missionary (12)
- # off-topic (10)
- # pathom (13)
- # polylith (10)
- # portal (28)
- # re-frame (37)
- # reitit (1)
- # releases (1)
- # shadow-cljs (30)
- # spacemacs (1)
- # tools-deps (9)
- # xtdb (10)
> richiardiandrea: Is there a way to stop a Jetty server started with :crux.http-server/server
?
> I use the reloaded pattern and I do call .close
on the node on stop but it seems the Http server is still running on restart and I get back a Address already in use
error
Hi there, I wanted to find if there was an answer to the question above. I could not find it and I am still receiving
Execution error (BindException) at (Net.java:-2).
Address already in use
When restarting the app cause Jetty remains started - I have also checked the CruxNode
defrecord but I don't see the http server...any hint?I think I found it under
(:server (:crux.http-server/server @(:!system node)))
Please let me know if this is considered an anti-pattern 😄
hey 🙂 sorry to be late to the party here....so are you saying that you had held on to a reference to the http server by looking it up inside the node
and storing it somewhere in your app state, preventing it from getting GC'd?
Or (on second reading) are you saying that you have a workaround you're happy enough with for the moment?
Hey Jeremy yes sorry that was late here and I was definitely tired :D So basically I needed a way to shut down the jetty server launched as a module I found the above as workaround, and in my component start I can now:
(assoc :node node
:http-server (-> node
:!system
deref
:crux.http-server/server
:server))
And in the component stop:
(:import
org.eclipse.jetty.server.Server)
...
(when (and http-server
(or (not (.isStopping ^Server http-server)) (not (.isStopped ^Server http-server))))
(.stop ^Server http-server))
I think the ideal solution would be to have :close-fn
on the node stop the server for me...I am calling it this way:
(when (and node (not (:closed? node))) (let [close-fn (:close-fn node)] (close-fn)))
Do you think it is worth a GitHub issue?The server record implements Closeable already (which runs .stop) and the xtdb.system wiring should be .close-ing everything properly...so I'm not sure why it's not actually stopping for you https://github.com/xtdb/xtdb/blob/master/modules/http-server/src/xtdb/http_server.clj#L238
are you leaving a pause between stopping and restarting? Looking at https://javadoc.io/doc/org.eclipse.jetty/jetty-server/latest/org.eclipse.jetty.server/org/eclipse/jetty/server/Server.html I see that STOPPING
is listed as a possible AbstractLifeCycle
field value :thinking_face:
I am on JVM plus linux but let me verify in isolation what is going on - your link clearly shows that you it is calling .stop
there
I think I found it under
(:server (:crux.http-server/server @(:!system node)))
Please let me know if this is considered an anti-pattern 😄