quarkus: Add support for applications which immediately exit
Sometimes an application doesn’t have any persistent services. Such applications should auto-exit after everything was “started”.
A good way to implement this might be for main-method startup build steps to indicate symbolically if they are persistent. Only a handful will be:
- Fixed thread pools like the scheduler
- I/O event loop threads
Notably, regular thread pools should not be considered persistent.
If no persistent services are started, then the shutdownRequested
flag should be immediately set, which will cause the main thread to exit cleanly (with no exit code). The shutdown hook will then run, but as the application was already stopped, it will immediately exit with no action taken.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 25
- Comments: 41 (28 by maintainers)
Commits related to this issue
- Add very basic support for command line only applications Relates to: #284 — committed to geoand/quarkus by geoand 5 years ago
- Add very basic support for command line only applications Relates to: #284 — committed to geoand/quarkus by geoand 5 years ago
- Add very basic support for command line only applications Relates to: #284 — committed to geoand/quarkus by geoand 5 years ago
- Add very basic support for command line only applications Relates to: #284 — committed to geoand/quarkus by geoand 5 years ago
- Add very basic support for command line only applications Relates to: #284 — committed to geoand/quarkus by geoand 5 years ago
Being able to easily create Quarkus CLIs might be a good way of keeping people for using Go for such tools
I’m almost finished with my current task, and this one will be next.
Excited to see that there already is discussion on how an integration with picocli could work. Actually, i am awaiting the quarkus cli-support to move a micronautfw CLI application to a more standard platform. Micronaut has helped me to get some initial prototype up an running but before sharing the tool with my coworkers or extendeding on it, i want to see it moved to a standard like Java/JakartaEE. I will keep monitoring this closely…
Would there be any interest in cooperation with the picocli project? Picocli has:
<cmd> ([-a=<a> -b=<b> -c=<c>] (-x | -y | -z))...
I’ve been on vacation for a few weeks and just got back. I intend to bring #2866 up to date with all the concerns addressed ASAP.
Just as an update, I’ve been working on a design proposal for this which I hope to have ready sometime next week.
I’m interested in helping with this… been in the go “dark” side for a while and have to admit that creating CLIs with things like cobra is quite pleasant and fast compared to what I’ve seen in the Java world last time I looked.
How can I help? Any stuff I could do to make it happen faster? Can’t wait to see picocli+Quarkus!!!
No but I could spitball a few concepts to see what sticks.
The simplest to implement would be to have a user-provided implementation of the proposed
ExecutionHandler
interface, which would look something like this:Another option would be to provide a “smart” annotation that could be applied to exactly one method on one application-scoped bean:
Share other ideas if you have them!
@remkop sure, I’d need to take another look at picocli, first, though as it’s been a while! 😄
I prefer the second option, it seems more clear and coherent with an usual main class. Also, exposing xecutionChain and ExecutionContext is making it too complex. People with basic knowledge of Java may be confused, while there is nothing confusing with @MainMethod and the List<String> args.
Any progress or timelines on this? I am highly interested as well.
Is there any example code somewhere of what this would look like?