Skip to content

Commit

Permalink
Mention exit handler parameter variant of Quarkus.run
Browse files Browse the repository at this point in the history
Fixes: #37929
  • Loading branch information
geoand committed Jan 3, 2024
1 parent 30c3267 commit 4f23903
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/src/main/asciidoc/lifecycle.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,42 @@ public class Main {
}
----

[TIP]
====
`Quarkus.run` also provides a version that allows the code to handle errors.
For example:
[source,java]
----
package com.acme;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
@QuarkusMain
public class Main {
public static void main(String... args) {
Quarkus.run(MyApp.class,
(exitCode, exception) -> {
// do whatever
},
args);
}
public static class MyApp implements QuarkusApplication {
@Override
public int run(String... args) throws Exception {
System.out.println("Do startup logic here");
Quarkus.waitForExit();
return 0;
}
}
}
----
====

=== Injecting the command line arguments

It is possible to inject the arguments that were passed in on the command line:
Expand Down

0 comments on commit 4f23903

Please sign in to comment.