Search in sources :

Example 1 with SingularityRunnerExceptionNotifier

use of com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier 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)

Example 2 with SingularityRunnerExceptionNotifier

use of com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier in project Singularity by HubSpot.

the class ArtifactManagerTest method setup.

@Before
public void setup() {
    SingularityRunnerBaseConfiguration baseConfig = new SingularityRunnerBaseConfiguration();
    SingularityS3Configuration s3Config = new SingularityS3Configuration();
    s3Config.setArtifactCacheDirectory(cacheDir.toString());
    artifactManager = new ArtifactManager(baseConfig, s3Config, LoggerFactory.getLogger(ArtifactManagerTest.class), new SingularityRunnerExceptionNotifier(baseConfig));
}
Also used : ArtifactManager(com.hubspot.singularity.s3.base.ArtifactManager) SingularityRunnerExceptionNotifier(com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier) SingularityRunnerBaseConfiguration(com.hubspot.singularity.runner.base.configuration.SingularityRunnerBaseConfiguration) SingularityS3Configuration(com.hubspot.singularity.s3.base.config.SingularityS3Configuration) Before(org.junit.Before)

Aggregations

SingularityRunnerExceptionNotifier (com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier)2 Injector (com.google.inject.Injector)1 MissingConfigException (com.hubspot.singularity.runner.base.config.MissingConfigException)1 SingularityRunnerBaseConfiguration (com.hubspot.singularity.runner.base.configuration.SingularityRunnerBaseConfiguration)1 ArtifactManager (com.hubspot.singularity.s3.base.ArtifactManager)1 SingularityS3Configuration (com.hubspot.singularity.s3.base.config.SingularityS3Configuration)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Before (org.junit.Before)1