From 00b1b84108a2f8f3a1b904b73b26618a5301939c Mon Sep 17 00:00:00 2001 From: Florian Sesser <florian@private.storage> Date: Thu, 8 Sep 2022 16:47:22 +0000 Subject: [PATCH] WIP: Convert Tahoe to receive its sockets from systemd refs #122 --- nixos/modules/tahoe.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/tahoe.nix b/nixos/modules/tahoe.nix index e4a83006..17641c47 100644 --- a/nixos/modules/tahoe.nix +++ b/nixos/modules/tahoe.nix @@ -115,6 +115,16 @@ in # Open up the firewall. # networking.firewall.allowedTCPPorts = flip mapAttrsToList cfg.introducers # (node: settings: settings.tub.port); + + # Make systemd open a port for us: + systemd.sockets.tahoe-web = { + description = "Tahoe Web Server Socket"; + wantedBy = [ "sockets.target" ]; + before = [ "multi-user.target" ]; + socketConfig.Accept = true; + socketConfig.ListenStream = settings.tub.port; + }; + systemd.services = flip mapAttrs' cfg.introducers (node: settings: let pidfile = "/run/tahoe.introducer-${node}.pid"; @@ -130,6 +140,8 @@ in serviceConfig = { Type = "simple"; PIDFile = pidfile; + Twisted wants non-blocking sockets: + NonBlocking = true; # Believe it or not, Tahoe is very brittle about the order of # arguments to $(tahoe run). The node directory must come first, # and arguments which alter Twisted's behavior come afterwards. -- GitLab