From c5f3b12f0484cd1a5152b6c64a336e9852d7c484 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 28 Aug 2020 23:17:28 -0400 Subject: feat(tvix): Support systemd socket activation When the nix daemon starts up, first check (using sd_listen_fds) whether we have been systemd socket-activated. If so, instead of passing the nix daemon socket path to grpc, start a manual accept(2) loop, passing the client file descriptors to grpc via AddInsecureChannelFromFd. There's an open grpc issue at https://github.com/grpc/grpc/issues/19133 for building support into grpc to do this automatically, but as of right now this appears to be the only way to make this happen. Making this happen, by the way, was a bit of a journey - at one point I attempted to ServerBuilder's experimental AddExternalConnectionAcceptor API, and that didn't work either - it appears that the final missing piece to getting this working was explicitly fcntl(2)ing the client file descriptors to set O_NONBLOCK before passing them into gRPC. With that set, this all works inside of the test vm. Fixes: b/56 Change-Id: I5d2ab2b5b02eb570249b30a9674e115c61b0ab0e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1882 Reviewed-by: kanepyork Reviewed-by: tazjin Tested-by: BuildkiteCI --- third_party/nix/default.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'third_party/nix/default.nix') diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix index ab54206492d0..3403b1a14c27 100644 --- a/third_party/nix/default.nix +++ b/third_party/nix/default.nix @@ -61,6 +61,7 @@ in lib.fix (self: pkgs.llvmPackages.libcxxStdenv.mkDerivation { grpc libseccomp libsodium + systemd.lib.dev openssl protobuf sqlite -- cgit 1.4.1