def run
      @op_mutex.synchronize do
        return AlreadyRunningError if @server

        @server_thread = Thread.new do
          @op_mutex.synchronize do
            begin
              wrapped_logger = Frankenstein::Server::WEBrickLogger.new(logger: @logger, progname: "Frankenstein::Server")
              @server = WEBrick::HTTPServer.new(Logger: wrapped_logger, BindAddress: nil, Port: @port, AccessLog: [[wrapped_logger, WEBrick::AccessLog::COMMON_LOG_FORMAT]])
              @server.mount "/", Rack::Handler::WEBrick, app
            rescue => ex
              #:nocov:
              @logger.fatal("Frankenstein::Server#run") { (["Exception while trying to create WEBrick::HTTPServer: #{ex.message} (#{ex.class})"] + ex.backtrace).join("\n  ") }
              #:nocov:
            ensure
              @op_cv.signal
            end
          end

          begin
            @server.start if @server
          rescue => ex
            #:nocov:
            @logger.fatal("Frankenstein::Server#run") { (["Exception while running WEBrick::HTTPServer: #{ex.message} (#{ex.class})"] + ex.backtrace).join("\n  ") }
            #:nocov:
          end
        end
      end

      @op_mutex.synchronize { @op_cv.wait(@op_mutex) until @server }
    end
def run
      @op_mutex.synchronize do
        return AlreadyRunningError if @server

        @server_thread = Thread.new do
          @op_mutex.synchronize do
            begin
              wrapped_logger = Frankenstein::Server::WEBrickLogger.new(logger: @logger, progname: "Frankenstein::Server")
              @server = WEBrick::HTTPServer.new(Logger: wrapped_logger, BindAddress: nil, Port: @port, AccessLog: [[wrapped_logger, WEBrick::AccessLog::COMMON_LOG_FORMAT]])
              @server.mount "/", Rack::Handler::WEBrick, app
            rescue => ex
              #:nocov:
              @logger.fatal("Frankenstein::Server#run") { (["Exception while trying to create WEBrick::HTTPServer: #{ex.message} (#{ex.class})"] + ex.backtrace).join("\n  ") }
              #:nocov:
            ensure
              @op_cv.signal
            end
          end

          begin
            @server.start if @server
          rescue => ex
            #:nocov:
            @logger.fatal("Frankenstein::Server#run") { (["Exception while running WEBrick::HTTPServer: #{ex.message} (#{ex.class})"] + ex.backtrace).join("\n  ") }
            #:nocov:
          end
        end
      end

      @op_mutex.synchronize { @op_cv.wait(@op_mutex) until @server }
    end
Create a new server instance.

 @param port [Integer] the TCP to listen on.

 @param logger [Logger] send log messages from WEBrick to this logger.
   If not specified, all log messages will be silently eaten.

 @param metrics_prefix [#to_s] The prefix to apply to the metrics exposed
   instrumenting the metrics server itself.

 @param registry [Prometheus::Client::Registry] if you want to use an existing
   metrics registry for this server, pass it in here.  Otherwise, a new one
   will be created for you, and be made available via #registry.

 Start the server instance running in a separate thread.

 This method returns once the server is just about ready to start serving
 requests.