From 37947d59eabde1612d872e0b0e86d769696ecc7e Mon Sep 17 00:00:00 2001 From: Jennifer Graul Date: Wed, 13 Sep 2023 13:32:47 +0200 Subject: [PATCH] headscale: fix reacting to SIGTERM The current version of headscale does not react to SIGTERMs and so it can only be terminated by a SIGKILL at the moment. This commit provides a patch to fix this. --- pkgs/servers/headscale/default.nix | 4 ++++ pkgs/servers/headscale/sigterm-fix.patch | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 pkgs/servers/headscale/sigterm-fix.patch diff --git a/pkgs/servers/headscale/default.nix b/pkgs/servers/headscale/default.nix index 8bb5a1eef31b..ad52bb94e89e 100644 --- a/pkgs/servers/headscale/default.nix +++ b/pkgs/servers/headscale/default.nix @@ -21,6 +21,10 @@ buildGoModule rec { patches = [ # backport of https://github.com/juanfont/headscale/pull/1697 ./trim-oidc-secret-path.patch + + # fix for headscale not reacting to SIGTERM + # see https://github.com/juanfont/headscale/pull/1480 and https://github.com/juanfont/headscale/issues/1461 + ./sigterm-fix.patch ]; ldflags = ["-s" "-w" "-X github.com/juanfont/headscale/cmd/headscale/cli.Version=v${version}"]; diff --git a/pkgs/servers/headscale/sigterm-fix.patch b/pkgs/servers/headscale/sigterm-fix.patch new file mode 100644 index 000000000000..22a97d98caac --- /dev/null +++ b/pkgs/servers/headscale/sigterm-fix.patch @@ -0,0 +1,12 @@ +diff --git a/hscontrol/app.go b/hscontrol/app.go +index b8dceba..4bcf019 100644 +--- a/hscontrol/app.go ++++ b/hscontrol/app.go +@@ -821,6 +821,7 @@ func (h *Headscale) Serve() error { + + // And we're done: + cancel() ++ return + } + } + }