Repository: vapor/vapor
File: Sources/Vapor/HTTP/Server/HTTPServer.swift (Swift)

Code before:
        switch configuration.address {
        case .hostname(let hostname, let port):
            addressDescription = "\(scheme)://\(hostname ?? Configuration.defaultHostname):\(port ?? Configuration.defaultPort)"
        case .unixDomainSocket(let socketPath):
            addressDescription = "\(scheme)+unix: \(socketPath)"
        }
        self.configuration.logger.debug("Server starting on \(addressDescription)")
        
        /// Start the actual `HTTPServer`.
        try self.connection.withLockedValue {
            $0 = try HTTPServerConnection.start(
                application: self.application,
                server: self,
                responder: self.responder,
                configuration: configuration,
                on: self.eventLoopGroup
            ).wait()
        }

        /// Override configuration with actual address.
        /// This may differ from the provided configuation if port 0 was provided, for example.
        if let localAddress = self.localAddress {
            if let hostname = localAddress.hostname, let port = localAddress.port {
                configuration.port = port
                configuration.hostname = hostname
                addressDescription = "\(scheme)://\(hostname):\(port)"
            }
        }

        /// Log started message with the actual configuration.
        self.configuration.logger.notice("Server started on \(addressDescription)")

        self.configuration = configuration
        self.didStart.withLockedValue { $0 = true }
    }
    
    public func shutdown() {
        guard let connection = self.connection.withLockedValue({ $0 }) else {
            return
        }
        self.configuration.logger.debug("Requesting HTTP server shutdown")
        do {
            try connection.close(timeout: self.configuration.shutdownTimeout).wait()
        } catch {
            self.configuration.logger.error("Could not stop HTTP server: \(error)")
        }
        self.configuration.logger.debug("HTTP server shutting down")
        self.didShutdown.withLockedValue { $0 = true }
    }

    public var localAddress: SocketAddress? {

Review comment (suggestion):
Don't know about this? We could also make `addressDescription` a method on `Configuration`.

Code after:
        case .hostname(let hostname, let port): 
            /// Override the hostname, port, neither, or both.
            configuration.address = .hostname(hostname ?? configuration.hostname, port: port ?? configuration.port)
        case .unixDomainSocket: 
            /// Override the socket path.
            configuration.address = address!
        }

        /// Log starting message for debugging before attempting to start the server.
        configuration.logger.debug("Server starting on \(configuration.addressDescription)")
        
        /// Start the actual `HTTPServer`.
        try self.connection.withLockedValue {
            $0 = try HTTPServerConnection.start(
                application: self.application,
                server: self,
                responder: self.responder,
                configuration: configuration,
                on: self.eventLoopGroup
            ).wait()
        }

        /// Overwrite configuration with actual address, if applicable.
        /// They may differ from the provided configuation if port 0 was provided, for example.
        if let localAddress = self.localAddress {
            if let hostname = localAddress.hostname, let port = localAddress.port {
                configuration.address = .hostname(hostname, port: port)
            } else if let pathname = localAddress.pathname {
                configuration.address = .unixDomainSocket(path: pathname)
            }
        }

        /// Log started message with the actual configuration.
        configuration.logger.notice("Server started on \(configuration.addressDescription)")

        self.configuration = configuration
        self.didStart.withLockedValue { $0 = true }
    }
    
    public func shutdown() {
        guard let connection = self.connection.withLockedValue({ $0 }) else {
            return
        }
        self.configuration.logger.debug("Requesting HTTP server shutdown")
        do {
            try connection.close(timeout: self.configuration.shutdownTimeout).wait()
        } catch {
            self.configuration.logger.error("Could not stop HTTP server: \(error)")
        }
        self.configuration.logger.debug("HTTP server shutting down")
        self.didShutdown.withLockedValue { $0 = true }