code: public static URL register(String serviceId, int port) {
          try {
              registry = SingletonServiceFactory.getBean(Registry.class);
              if (registry == null)
                  throw new RuntimeException("Could not find registry instance in service map");
              // in kubernetes pod, the hostIP is passed in as STATUS_HOST_IP environment
              // variable. If this is null
              // then get the current server IP as it is not running in Kubernetes.
              String ipAddress = System.getenv(STATUS_HOST_IP);
              logger.info("Registry IP from STATUS_HOST_IP is " + ipAddress);
              if (ipAddress == null) {
                  InetAddress inetAddress = Util.getInetAddress();
                  ipAddress = inetAddress.getHostAddress();
                  logger.info("Could not find IP from STATUS_HOST_IP, use the InetAddress " + ipAddress);
              }
  
              ServerConfig serverConfig = getServerConfig();
              Map parameters = new HashMap<>();
              if (serverConfig.getEnvironment() != null)
                  parameters.put(ENV_PROPERTY_KEY, serverConfig.getEnvironment());
              URL serviceUrl = new URLImpl("light", ipAddress, port, serviceId, parameters);
              if (logger.isInfoEnabled()) logger.info("register service: " + serviceUrl.toFullStr());
              registry.register(serviceUrl);
              return serviceUrl;
              // handle the registration exception separately to eliminate confusion
          } catch (Exception e) {
              System.out.println("Failed to register service, the server stopped.");
              e.printStackTrace();
              if (logger.isInfoEnabled())
                  logger.info("Failed to register service, the server stopped.", e);
              throw new RuntimeException(e.getMessage());
          }
  
      }
docs: Register the service to the Consul or other service registry. Make it as a separate static method so that it
  can be called from light-hybrid-4j to register individual service.
  
  @param serviceId Service Id that is registered
  @param port Port number of the service