Write the Server main entry

In auth-service/src/main/java/AuthServer.java’s main() method:

  1. Use ServerBuilder to build a new server that listens on port 9091
  2. Add an instance of AuthServiceImpl as a service: builder.addService(…)
// TODO Use ServerBuilder to create a new Server instance. Start it, and await termination.
// Algorithm and "auth-issuer" are used for JWT signing and verification.
Algorithm algorithm = Algorithm.HMAC256("secret");
Server server = ServerBuilder.forPort(9091)
  .addService(new AuthServiceImpl(repository, "auth-issuer", algorithm))
  .build();
  1. Add a shutdown hook to shutdown the server in case the process receives shutdown signal. This will try to shutdown the server gracefully, if shutdown hook is called.
Runtime.getRuntime().addShutdownHook(new Thread() {
  @Override
  public void run() {
    server.shutdownNow();
  }
});
  1. Start the server:
server.start();
logger.info("Server started on port 9091");
  1. Server will be running in a background thread. Call server.awaitTermination() to block the main thread
server.awaitTermination();