Search in sources :

Example 1 with MissingConfigException

use of com.hubspot.singularity.runner.base.config.MissingConfigException in project Singularity by HubSpot.

the class SingularityRunner method run.

@SuppressFBWarnings("DM_EXIT")
public void run(Iterable<? extends Module> modules) {
    final Injector injector = Guice.createInjector(Stage.PRODUCTION, modules);
    final SingularityRunnerExceptionNotifier exceptionNotifier = injector.getInstance(SingularityRunnerExceptionNotifier.class);
    final SingularityDriver driver = injector.getInstance(SingularityDriver.class);
    Runtime.getRuntime().addShutdownHook(new Thread("SingularityRunnerGracefulShutdown") {

        @Override
        public void run() {
            driver.shutdown();
        }
    });
    try {
        driver.startAndWait();
        LOG.info("Exiting normally");
        System.exit(0);
    } catch (MissingConfigException mce) {
        LOG.error("Missing required configuration, exiting", mce);
        System.exit(1);
    } catch (Throwable t) {
        LOG.error("Caught unexpected exception, exiting", t);
        exceptionNotifier.notify(String.format("Unexpected exception in runner (%s)", t.getMessage()), t, Collections.<String, String>emptyMap());
        System.exit(1);
    }
}
Also used : SingularityRunnerExceptionNotifier(com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier) Injector(com.google.inject.Injector) MissingConfigException(com.hubspot.singularity.runner.base.config.MissingConfigException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

Injector (com.google.inject.Injector)1 MissingConfigException (com.hubspot.singularity.runner.base.config.MissingConfigException)1 SingularityRunnerExceptionNotifier (com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1