Add support for systemd socket activation #704
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Systemd has a feature whereby it can manage the listening sockets for a network service, and launch the service in response to the first incoming connection, passing the open socket to the service process via an open file descriptor. This PR adds support for socket activation to
webhook
.This PR builds on my previous #703 that added platform-specific logic to the socket binding process. On compatible platforms (i.e. not Windows) we now check whether we have been launched with the standard environment variables that indicate systemd socket activation - if so, we simply use the already-open socket we have been given by systemd instead of opening our own. In this mode any
-port
and-socket
options are ignored completely in favour of the systemd socket.As per the discussion on #703 I've also made it a fatal error to try and combine the
-socket
and-setuid
options. Socket activation provides a safer way to achieve the equivalent behaviour of running webhook as an unprivileged user but have it listening on a Unix socket owned by root.Testing
I can't really see an easy way to add tests for this feature, but I have been using my own build of this branch in production to run webhook with socket activation.