def run(args = {})
      @at_stop = []

      extra_options = parse_cli_options!(args)

      # Boot app first, 'cause it might change
      # configuration, loggin settings, etc.
      boot_app!

      parse_gem_options!(extra_options)

      configure_server!

      logger.info "Starting AnyCable gRPC server (pid: #{Process.pid})"

      print_versions!

      logger.info "Serving #{defined?(::Rails) ? 'Rails ' : ''}application from #{boot_file}"

      verify_connection_factory!

      log_grpc! if config.log_grpc

      log_errors!

      @server = AnyCable::Server.new(
        host: config.rpc_host,
        **config.to_grpc_params,
        interceptors: AnyCable.middleware.to_a
      )

      # Make sure middlewares are not adding after server has started
      AnyCable.middleware.freeze

      start_health_server! if config.http_health_port_provided?
      start_pubsub!

      server.start

      run_custom_server_command! unless server_command.nil?

      begin
        wait_till_terminated
      rescue Interrupt => e
        logger.info "Stopping... #{e.message}"

        shutdown

        logger.info "Stopped. Good-bye!"
        exit(0)
      end
    end
def run(args = {})
      @at_stop = []

      extra_options = parse_cli_options!(args)

      # Boot app first, 'cause it might change
      # configuration, loggin settings, etc.
      boot_app!

      parse_gem_options!(extra_options)

      configure_server!

      logger.info "Starting AnyCable gRPC server (pid: #{Process.pid})"

      print_versions!

      logger.info "Serving #{defined?(::Rails) ? 'Rails ' : ''}application from #{boot_file}"

      verify_connection_factory!

      log_grpc! if config.log_grpc

      log_errors!

      @server = AnyCable::Server.new(
        host: config.rpc_host,
        **config.to_grpc_params,
        interceptors: AnyCable.middleware.to_a
      )

      # Make sure middlewares are not adding after server has started
      AnyCable.middleware.freeze

      start_health_server! if config.http_health_port_provided?
      start_pubsub!

      server.start

      run_custom_server_command! unless server_command.nil?

      begin
        wait_till_terminated
      rescue Interrupt => e
        logger.info "Stopping... #{e.message}"

        shutdown

        logger.info "Stopped. Good-bye!"
        exit(0)
      end
    end
rubocop:disable Metrics/AbcSize, Metrics/MethodLength