use of org.apache.bookkeeper.http.HttpServer in project bookkeeper by apache.
the class AutoRecoveryMain method main.
public static void main(String[] args) {
ServerConfiguration conf = null;
try {
conf = parseArgs(args);
} catch (IllegalArgumentException iae) {
LOG.error("Error parsing command line arguments : ", iae);
System.err.println(iae.getMessage());
printUsage();
System.exit(ExitCode.INVALID_CONF);
}
try {
final AutoRecoveryMain autoRecoveryMain = new AutoRecoveryMain(conf);
autoRecoveryMain.start();
HttpServerLoader.loadHttpServer(conf);
final HttpServer httpServer = HttpServerLoader.get();
if (conf.isHttpServerEnabled() && httpServer != null) {
BKHttpServiceProvider serviceProvider = new BKHttpServiceProvider.Builder().setAutoRecovery(autoRecoveryMain).setServerConfiguration(conf).build();
httpServer.initialize(serviceProvider);
httpServer.startServer(conf.getHttpServerPort());
}
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
autoRecoveryMain.shutdown();
if (httpServer != null && httpServer.isRunning()) {
httpServer.stopServer();
}
LOG.info("Shutdown AutoRecoveryMain successfully");
}
});
LOG.info("Register shutdown hook successfully");
autoRecoveryMain.join();
System.exit(autoRecoveryMain.getExitCode());
} catch (Exception e) {
LOG.error("Exception running AutoRecoveryMain : ", e);
System.exit(ExitCode.SERVER_EXCEPTION);
}
}
Aggregations