Closed MafcoCinco closed 5 years ago
I think that this is the intended behavior; when "run-cmd" terminates, everything goes down. So I would wait until you are ready to close to return from run-cmd.
Fair enough. I have a PR ready to add this by adding a tag to the sub-command map called keep-alive
which will not call the termination. Sounds like a I should not bother, correct?
I think so 😄 - but I thank you for taking the time to submit an idea and hacking on it!
Sure thing. Thanks for your response. Much appreciated!
A slightly less hard-on-the-cpu action that seems to work for me is to use core.async and stick (let [c (a/chan)] (a/<!! c))
at the bottom of your :runs
fn.
I agree though: this and (while true)
seem a bit hacky. I'd 👍 either a way to declare that the JVM should wait around in the command map, or get this into the docs as a gotcha.
@rgm @MafcoCinco see #84
I've run into an issue with http-kit server and CLI-matic. My project uses CLI-matic to implement multiple entry points via sub-commands for use in a Kubernetes/Docker environment. Each sub-command represents a different service and is used as a different entry-point for a Docker container.
The problem I encountered was that CLI-matic seems to run exit handling as soon as
run-cmd*
completes. This causes my http-kit service to immediately exit afterrun-server
is called as the server is launched asynchronously, returning a function that can be used in the main thread to shut down the service, which then promptly happens.I have worked around this by adding
(while true)
after my call torun-server
but this is less than ideal. It seems to me to be a code smell to need to include this in every service sub-command and additionally, myon-shutdown
handler does not seem to be called correctly with this work around. That was surprising to me and perhaps is related to something else that I'm not thinking of.Either way, any thoughts on how best to handle this use case would be greatly appreciated. Thanks for your time.