Search in sources :

Example 1 with BaseServerStartup

use of com.netflix.zuul.netty.server.BaseServerStartup in project zuul by Netflix.

the class Bootstrap method start.

public void start() {
    long startNanos = System.nanoTime();
    logger.info("Zuul Sample: starting up.");
    int exitCode = 0;
    Server server = null;
    try {
        Injector injector = Guice.createInjector(new ZuulSampleModule());
        BaseServerStartup serverStartup = injector.getInstance(BaseServerStartup.class);
        server = serverStartup.server();
        server.start();
        long startupDuration = System.nanoTime() - startNanos;
        logger.info("Zuul Sample: finished startup. Duration = {}ms", TimeUnit.NANOSECONDS.toMillis(startupDuration));
        server.awaitTermination();
    } catch (Throwable t) {
        // Don't use logger here, as we may be shutting down the JVM and the logs won't be printed.
        t.printStackTrace();
        System.err.println("###############");
        System.err.println("Zuul Sample: initialization failed. Forcing shutdown now.");
        System.err.println("###############");
        exitCode = 1;
    } finally {
        // server shutdown
        if (server != null) {
            server.stop();
        }
        System.exit(exitCode);
    }
}
Also used : Server(com.netflix.zuul.netty.server.Server) Injector(com.google.inject.Injector) BaseServerStartup(com.netflix.zuul.netty.server.BaseServerStartup)

Aggregations

Injector (com.google.inject.Injector)1 BaseServerStartup (com.netflix.zuul.netty.server.BaseServerStartup)1 Server (com.netflix.zuul.netty.server.Server)1