immutant

http://immutant.org Note: dev discussion happens in #immutant on FreeNode IRC.
richiardiandrea 2016-06-28T20:39:25.000158Z

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

2016-06-28T20:48:53.000161Z

@richiardiandrea: what does wait-for-close do? block until the server exits?

2016-06-28T20:50:45.000162Z

the web server doesn't close until you close it, so I'm curious what your need really is?

richiardiandrea 2016-06-28T20:51:45.000163Z

Yes it does block the main Thread

2016-06-28T20:51:55.000164Z

@richiardiandrea: immutant.util/at-exit may help you. also, maybe look at https://issues.jboss.org/browse/IMMUTANT-605

richiardiandrea 2016-06-28T20:52:35.000165Z

Oh ok I'll have a look

richiardiandrea 2016-06-28T20:56:56.000166Z

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

2016-06-28T20:57:36.000167Z

sure thing. if that doesn't meet all your needs, holler and maybe we can figure something out

richiardiandrea 2016-06-28T21:42:47.000169Z

thanks! I think I will need to wait on a promise that will be filled on at-exit

richiardiandrea 2016-06-28T22:04:26.000172Z

Simple enough 😄

(defn wait-for-close
  []
  (let [promise (promise)]
    (immutant.util/at-exit #(deliver promise "please shutdown"))
    @promise))

2016-06-28T22:07:00.000175Z

@richiardiandrea: so i assume it makes no sense for you to do whatever you're waiting to do in the at-exit itself?

richiardiandrea 2016-06-28T22:07:20.000176Z

no I basically need to block the main thread from exiting

richiardiandrea 2016-06-28T22:08:08.000177Z

an alternative would be to have non-daemon threads running, so if the server can be set to have non-daemon threads

richiardiandrea 2016-06-28T22:08:20.000178Z

I would not even need the above workaround

2016-06-28T22:14:07.000179Z

i think i've seen some xnio daemon option somewhere. not sure how exposed it is.

richiardiandrea 2016-06-28T22:15:47.000180Z

quickly googling brings up this: https://github.com/spring-projects/spring-boot/commit/b79ee145d613bac8a0a58b28fc600f7ef9086621

richiardiandrea 2016-06-28T22:16:13.000182Z

they actually have the opposite problem there 😉

2016-06-28T22:17:10.000184Z

but it appears its default value is false

richiardiandrea 2016-06-28T22:17:20.000185Z

uhm

richiardiandrea 2016-06-28T22:19:15.000188Z

spotted 😉

2016-06-28T22:20:53.000189Z

ah-hah! 🙂

2016-06-28T22:22:19.000191Z

lemme see if that's still needed

2016-06-28T22:30:31.000192Z

@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.

2016-06-28T22:42:58.000193Z

yeah, i'm almost sure that was a workaround for a bug now obsolete with the versions of undertow & xnio we're currently using

richiardiandrea 2016-06-28T22:57:09.000194Z

ok good, I'd be glad to try it, let me know when it is up ok?

richiardiandrea 2016-06-28T22:57:56.000195Z

just one thing to keep in mind is that now the JVM won't exit until the server shuts down

2016-06-28T23:03:41.000196Z

i'm not seeing that locally. it's possible something else (undertow?) in the stack is doing it now

richiardiandrea 2016-06-28T23:05:10.000197Z

yeah it is possible that this is kind of hidden by the fact that run is executed in -main directly