private static void startWebServer()

in src/main/java/com/google/gcs/sdrs/SdrsApplication.java [89:123]


  private static void startWebServer() {
    try {

      // Read config values
      Boolean useHttps = xmlConfig.getBoolean("serverConfig.useHttps");
      String hostName = xmlConfig.getString("serverConfig.address");
      int port = xmlConfig.getInt("serverConfig.port");
      long shutdownGracePeriodInSeconds =
          xmlConfig.getLong("serverConfig.shutdownGracePeriodInSeconds");

      // Build server URI
      URI baseUri =
          UriBuilder.fromUri((useHttps ? "https://" : "http://") + hostName + "/")
              .port(port)
              .build();

      server = GrizzlyHttpServerFactory.createHttpServer(baseUri, new AppResourceConfig());

      // Register shutdown hook so the monitoring thread is killed when the app is stopped
      Runtime.getRuntime()
          .addShutdownHook(
              new Thread(
                  new ServerShutdownHook(server, shutdownGracePeriodInSeconds, false),
                  "shutdownHook"));

      server.start();
      logger.info("SDRS Web Server Started.");
    } catch (IOException ex) {
      logger.error("An error occurred during web server start up: " + ex.getCause());
      if (server != null && server.isStarted()) {
        server.shutdownNow();
      }
      System.exit(1);
    }
  }