Created
December 18, 2018 04:06
-
-
Save abhirockzz/12033adb8166c8654021751ca40baa3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void bootstrap() throws IOException { | |
String hostname = "0.0.0.0"; | |
String port = "9090"; | |
URI baseUri = UriBuilder.fromUri("http://" + hostname + "/").port(Integer.parseInt(port)).build(); | |
ResourceConfig config = new ResourceConfig(ServiceManagerResource.class); | |
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); | |
LOGGER.log(Level.INFO, "Application accessible at {0}", baseUri.toString()); | |
//gracefully exit Grizzly services when app is shut down | |
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { | |
@Override | |
public void run() { | |
LOGGER.log(Level.INFO, "Exiting......"); | |
try { | |
server.shutdownNow(); | |
LOGGER.log(Level.INFO, "REST services stopped"); | |
ServiceLifecycleManager.getInstance().stop(); | |
LOGGER.log(Level.INFO, "Twitter producer stopped"); | |
} catch (Exception ex) { | |
//log & continue.... | |
LOGGER.log(Level.SEVERE, ex, ex::getMessage); | |
} | |
} | |
})); | |
server.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment