public static void main(String[] args) { final StandaloneServer server = new StandaloneServer(); JCommander jc = new JCommander(server); jc.parse(args); if (server.help) { jc.usage(); Unsafe.systemExit(ExitCodes.USAGE.ordinal()); return; } server.start(); // Try to clean up when the server is stopped. Runtime.getRuntime().addShutdownHook( new Thread(new Runnable() { @Override public void run() { LOG.info("Stopping server"); server.stop(); LOG.info("Server stopped"); } })); try { server.join(); } catch (InterruptedException e) { // Reset interruption Thread.currentThread().interrupt(); // And exit now. return; } }
public static void main(String[] args) { final StandaloneServer server = new StandaloneServer(); JCommander jc = new JCommander(server); jc.parse(args); if (server.help) { jc.usage(); Unsafe.systemExit(ExitCodes.USAGE.ordinal()); return; } server.start(); // Try to clean up when the server is stopped. Runtime.getRuntime().addShutdownHook( new Thread(new Runnable() { @Override public void run() { LOG.info("Stopping server"); server.stop(); LOG.info("Server stopped"); } })); try { server.join(); } catch (InterruptedException e) { // Reset interruption Thread.currentThread().interrupt(); // And exit now. return; } }
public void start() { if (null != server) { LOG.error("The server was already started"); Unsafe.systemExit(ExitCodes.ALREADY_STARTED.ordinal()); return; } try { JdbcMeta meta = new JdbcMeta(url); LocalService service = new LocalService(meta); // Construct the server this.server = new HttpServer.Builder() .withHandler(service, serialization) .withPort(port) .build(); // Then start it server.start(); LOG.info("Started Avatica server on port {} with serialization {}", server.getPort(), serialization); } catch (Exception e) { LOG.error("Failed to start Avatica server", e); Unsafe.systemExit(ExitCodes.START_FAILED.ordinal()); } }
public void start() { if (null != server) { LOG.error("The server was already started"); Unsafe.systemExit(ExitCodes.ALREADY_STARTED.ordinal()); return; } try { JdbcMeta meta = new JdbcMeta(url); LocalService service = new LocalService(meta); // Construct the server this.server = new HttpServer.Builder() .withHandler(service, serialization) .withPort(port) .build(); // Then start it server.start(); LOG.info("Started Avatica server on port {} with serialization {}", server.getPort(), serialization); } catch (Exception e) { LOG.error("Failed to start Avatica server", e); Unsafe.systemExit(ExitCodes.START_FAILED.ordinal()); } }