title: Gracefully exiting quarkus during startup lifecycle
body: <p><a href="https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/how.20can.20i.20fail.20during.20application.20startup.20.3F" rel="nofollow noreferrer">relevant zulip chat</a></p>
  <p>I am trying to figure how you are supposed to gracefully fail during application startup in quarkus.</p>
  <ol>
  <li>i tried adding this to the application startup code. This is right now not being called if i run one of the unit tests. It is only called if i start the application directly. I was hoping to return a non zero value as oppose to throwing an exception. This might be the recomended approach. I am not sure.</li>
  </ol>
  <pre><code>    public class MyApp implements QuarkusApplication {
  
          @Override
          public int run(String... args) throws Exception {
              System.out.println(&quot;Do startup logic here&quot;);
              Quarkus.waitForExit();
              return 0;
          }
  </code></pre>
  <ol start="2">
  <li>i also tried raising an exception from the onStart lifecycle event. But it seems quarkus kept continuing its execution</li>
  </ol>
  <pre><code>   void onStart(@Observes StartupEvent ev) {               
          LOGGER.info(&quot;The application is starting...&quot;);
      }
  
      void onStop(@Observes ShutdownEvent ev) {               
          LOGGER.info(&quot;The application is stopping...&quot;);
      }
  </code></pre>
  <p>I am not sure if this is a feature request a bug or i am missing something and this is normal behaviour.</p>
  <p>Edit1:
  Just to be clear:</p>
  <pre><code>@Startup
  @ApplicationScoped
  public class StarterBean {
      private static final Logger LOGGER = Logger.getLogger(&quot;&quot;);
  
      public StarterBean() {
          throw new RuntimeException(&quot;failed misrably&quot;);
      }
  }
  </code></pre>
  <p>when i run with &quot;./gradlew quarkusDev` i see the exception in the console but the application never exists. I was thinking it should. It does exit during unit tests and properly fails. I tried moving the exception in the onStart and that did not help as well. I also tried combinations of having each of Startup,ApplicationScoped or both</p>
  <p>Edit2:</p>
  <p>I tested it by building the uber jar and running that. Raising the exception does quit the application. Also as one can imagine the application also exits when running in the docker container. I am puzzled why the gradle task never exist. So to that end i think i will accept the answer . Thank you so much for your help !</p>