Sorry for the crosspost but is there a way to wait for the immutant server to close? akin to aleph's wait-for-close
https://github.com/ztellman/aleph/blob/master/src/aleph/netty.clj#L732
@richiardiandrea: what does wait-for-close
do? block until the server exits?
the web server doesn't close until you close it, so I'm curious what your need really is?
Yes it does block the main Thread
@richiardiandrea: immutant.util/at-exit may help you. also, maybe look at https://issues.jboss.org/browse/IMMUTANT-605
Oh ok I'll have a look
It is a common problem when Java is executing all daemon threads, which are not stopping the JVM to shutdown...checking checking...thanks a lot
sure thing. if that doesn't meet all your needs, holler and maybe we can figure something out
thanks! I think I will need to wait on a promise that will be filled on at-exit
Simple enough 😄
(defn wait-for-close
[]
(let [promise (promise)]
(immutant.util/at-exit #(deliver promise "please shutdown"))
@promise))
@richiardiandrea: so i assume it makes no sense for you to do whatever you're waiting to do in the at-exit itself?
no I basically need to block the main thread from exiting
an alternative would be to have non-daemon threads running, so if the server can be set to have non-daemon threads
I would not even need the above workaround
i think i've seen some xnio daemon option somewhere. not sure how exposed it is.
quickly googling brings up this: https://github.com/spring-projects/spring-boot/commit/b79ee145d613bac8a0a58b28fc600f7ef9086621
they actually have the opposite problem there 😉
http://docs.jboss.org/xnio/3.0.4.GA/api/org/xnio/Options.html#THREAD_DAEMON
but it appears its default value is false
uhm
spotted 😉
ah-hah! 🙂
lemme see if that's still needed
@richiardiandrea: all tests are passing for me locally without setting that option. i've only tested in one container, and i'd like to confer with @tcrawley that we're actually testing the condition that code is affecting, but i think we can safely remove that. which is good, cuz i don't like that we're setting it.
yeah, i'm almost sure that was a workaround for a bug now obsolete with the versions of undertow & xnio we're currently using
ok good, I'd be glad to try it, let me know when it is up ok?
just one thing to keep in mind is that now the JVM won't exit until the server shuts down
i'm not seeing that locally. it's possible something else (undertow?) in the stack is doing it now
yeah it is possible that this is kind of hidden by the fact that run
is executed in -main
directly