Add support for "sd_listen_fds
" socket activation socket support for gRPC and HTTP listeners
#589
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.
What this PR does:
This pull request adds support for server to be used with systemd's socket activation by expecting an open file descriptor to be announced using environment variables.
To make use of this set either
HTTPListenNetwork
orGRPCListenNetwork
to"sd_listen_fd"
andHTTPListenAddress
orGRPCListenAddress
either to an ASCII string passed as theFileDescriptorName=
from a systemd.socket unit or"LISTEN_FD_$n"
, where$n
is the file descriptor number, starting with 3 (SD_LISTEN_FDS_START
).By default, when using
"sd_listen_fd"
, the address will be"LISTEN_FD_3"
.This patch makes use of the coreos/go-systemd/v22/activation library (which was already included as an indirect dependency). Unfortunately their implementation doesn't allow call sites to get a view of the listeners both by file descriptor number and file descriptor name, as the highlevel helpers cannot be used.
This is similar in spirit to #511, I'll happily include unix socket support in the
listen
helper this change introduces as part of the rebase.Which issue(s) this PR fixes:
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]