docs: public static void main(String[] args) {
  
          final InputStream initialInput = new Base64InputStream(System.in);
          final PrintStream initialError = System.err;
  
          // Make sure our original stdio is properly captured.
          try {
              Class.forName(ConsoleHandler.class.getName(), true, ConsoleHandler.class.getClassLoader());
          } catch (Throwable ignored) {
          }
  
          // Install JBoss Stdio to avoid any nasty crosstalk.
          StdioContext.install();
          final StdioContext context = StdioContext.create(
              new NullInputStream(),
              new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stdout"), Level.INFO),
              new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stderr"), Level.ERROR)
          );
          StdioContext.setStdioContextSelector(new SimpleStdioContextSelector(context));
  
          final byte[] asAuthBytes = new byte[ProcessController.AUTH_BYTES_ENCODED_LENGTH];
          try {
              StreamUtils.readFully(initialInput, asAuthBytes);
          } catch (IOException e) {
              e.printStackTrace();
              SystemExiter.abort(ExitCodes.FAILED);
              throw new IllegalStateException(); // not reached
          }
  
          final MarshallerFactory factory = Marshalling.getMarshallerFactory("river", DomainServerMain.class.getClassLoader());
          final Unmarshaller unmarshaller;
          final ByteInput byteInput;
          final AsyncFuture<ServiceContainer> containerFuture;
          try {
              Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.vfs")));
              final MarshallingConfiguration configuration = new MarshallingConfiguration();
              configuration.setVersion(2);
              configuration.setClassResolver(new SimpleClassResolver(DomainServerMain.class.getClassLoader()));
              unmarshaller = factory.createUnmarshaller(configuration);
              byteInput = Marshalling.createByteInput(initialInput);
              unmarshaller.start(byteInput);
              final ServerTask task = unmarshaller.readObject(ServerTask.class);
              unmarshaller.finish();
              containerFuture = task.run(Arrays.<ServiceActivator>asList(new ServiceActivator() {
                  @Override
                  public void activate(final ServiceActivatorContext serviceActivatorContext) {
                      // TODO activate host controller client service
                  }
              }));
          } catch (Throwable t) {
              t.printStackTrace(initialError);
              SystemExiter.abort(ExitCodes.FAILED);
              throw new IllegalStateException(); // not reached
          }
  
          Throwable caught = null;
          for (;;) {
              try {
                  final String scheme = StreamUtils.readUTFZBytes(initialInput);
  //                String scheme = "remote";
                  final String hostName = StreamUtils.readUTFZBytes(initialInput);
                  final int port = StreamUtils.readInt(initialInput);
                  final boolean managementSubsystemEndpoint = StreamUtils.readBoolean(initialInput);
                  final byte[] authBytes = new byte[ProcessController.AUTH_BYTES_ENCODED_LENGTH];
                  StreamUtils.readFully(initialInput, authBytes);
                  final String authKey = new String(authBytes, Charset.forName("US-ASCII"));
                  URI hostControllerUri = new URI(scheme, null, NetworkUtils.formatPossibleIpv6Address(hostName), port, null, null, null);
                  // Get the host-controller server client
                  final ServiceContainer container = containerFuture.get();
                  if (!container.isShutdown()) {
                      // otherwise, ServiceNotFoundException or IllegalStateException is thrown because HostControllerClient is stopped
                      final HostControllerClient client = getRequiredService(container,
                              HostControllerConnectionService.SERVICE_NAME, HostControllerClient.class);
                      // Reconnect to the host-controller
                      client.reconnect(hostControllerUri, authKey, managementSubsystemEndpoint);
                  }
  
              } catch (InterruptedIOException e) {
                  Thread.interrupted();
                  // ignore
              } catch (EOFException e) {
                  // this means it's time to exit
                  break;
              } catch (Throwable t) {
                  t.printStackTrace();
                  caught = t;
                  break;
              }
          }
  
          // Once the input stream is cut off, shut down
          // We may be attempting a graceful shutdown, in which case we need to wait
          final ServiceContainer container;
          try {
              container = containerFuture.get();
              ServiceController<?> controller = container.getService(GracefulShutdownService.SERVICE_NAME);
              if(controller != null) {
                  ((GracefulShutdownService)controller.getValue()).awaitSuspend();
              }
          } catch (InterruptedException ie) {
              // ignore this and exit
          } catch (Throwable  t) {
              t.printStackTrace();
          } finally {
              if (caught == null) {
                  SystemExiter.logAndExit(ServerLogger.ROOT_LOGGER::shuttingDownInResponseToProcessControllerSignal, ExitCodes.NORMAL);
              } else {
                  SystemExiter.abort(ExitCodes.FAILED);
              }
          }
          throw new IllegalStateException(); // not reached
      }