Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ability to recognize and execute user main method(s) #6499

Open
dmlloyd opened this issue Jan 10, 2020 · 4 comments
Open

Introduce ability to recognize and execute user main method(s) #6499

dmlloyd opened this issue Jan 10, 2020 · 4 comments

Comments

@dmlloyd
Copy link
Member

@dmlloyd dmlloyd commented Jan 10, 2020

Description
Introduce ability to recognize and execute user main method(s).

Requirements

  • Introduce a means to identify a method as a main method (e.g. an annotation)
  • Allow build-time configuration to specify which main method (if any) should be used for the build (can @Named be used for this?)
  • The main method should be allowed to optionally accept a String[] or List<String> which contains the command arguments (minus the arguments processed by #6497)
  • The main method should be allowed to optionally return an int which contains the desired exit code
  • If the application shutdown fails with an exception, there should be a means to override the exit code.
  • A mechanism may be defined to allow users to customize the mapping of exception to exit code; if implemented, the mechanism should accept the exception and the originally requested exit code, and return the new exit code. If the mapping fails with an exception, an exit code of 1 should be used.
  • System.exit() should be called with the final exit code once all shutdown work is complete (at the end of the launcher main method).
  • If no main method is defined, then the waitForExit method defined in #6498 should be used, with the code returned from that method being used as the requested exit code

Exit codes reference

Code Description
0 Normal exit (no error, clean shutdown)
1 Exit due to uncaught exception
2 Exit due to configuration or usage error
10 (reserved due to its usage with JBoss)
@maxandersen

This comment has been minimized.

Copy link
Contributor

@maxandersen maxandersen commented Jan 14, 2020

Reading the proposed items I'm struggling to figure out if I'll be able to as follows:

class Main {
public static void main(String... args) {
    QuarkusApplication.start(Main::handler, args); 
} 

int handler(String... args) {
   ...
}
}

here I'm just using a method reference, but could also be a class.

Main point is that I'll have a plain static main that can be booted by Quarkus.

Or is the expectation all is always handled by Quarkus ?

@dmlloyd

This comment has been minimized.

Copy link
Member Author

@dmlloyd dmlloyd commented Jan 14, 2020

That seems doable to me. We just have to be sure that the Quarkus build process has a way to know which entry point main to use during build.

@maxandersen

This comment has been minimized.

Copy link
Contributor

@maxandersen maxandersen commented Jan 14, 2020

Yes, I assume we'll have a way to do both - the explicit main() method is mainly just for easy launching from IDE or command line jar runs.

@dodalovic

This comment has been minimized.

Copy link
Contributor

@dodalovic dodalovic commented Jan 18, 2020

@maxandersen Just curious how far we are from this wonderful feature?
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.