Vapor v4.29.0 Release Notes
Release Date: 2020-08-20 // over 3 years ago-
๐ ###### This patch was authored by @dimitribouniol and released by @MrLotU.
โ Adds support for Unix Domain Sockets (#2471, #2226, #2371).
A server can be started using the
serve
command:vapor run serve --unix-socket /tmp/vapor.socket
๐ง Alternatively, the app can be configured in code to connect to a socket:
app.http.server.configuration.unixDomainSocketPath = "/tmp/vapor.socket"
In either scenario, if a socket path is specified, it takes precedence over binding the server to a hostname/port. Note that TLS may be combined with this options if you wish the server to only listen to encrypted connections made to the socket file.
The socket file must not exist prior to starting the server. If one is left behind during an incomplete shutdown, however, and the app has permission to delete it, it will be overidden.
To assist with making connections to socket paths,
URI.Scheme
has a.httpUnixDomainSocket
property.try app.client.get(.init(scheme: .httpUnixDomainSocket, host: "/tmp/vapor.socket", path: "/foo"))