From ba1798ce468ebb74cb1ea28c7f2ad642b357e198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Gro=C3=9Fe=20Sundrup?= Date: Fri, 29 Dec 2023 22:09:22 +0100 Subject: [PATCH] if socket-activated, exit after printing --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index e0abca2..d068ba4 100644 --- a/main.go +++ b/main.go @@ -69,7 +69,8 @@ func main() { var l net.Listener var err error - if os.Getenv("LISTEN_PID") == strconv.Itoa(os.Getpid()) { + var isSocketActivated = os.Getenv("LISTEN_PID") == strconv.Itoa(os.Getpid()) + if isSocketActivated { l, err = net.FileListener(os.NewFile(3, "systemd-socket")) } else { l, err = net.Listen("tcp", *CONN_HOST+":"+*CONN_PORT) @@ -102,6 +103,10 @@ func main() { } } + if isSocketActivated { + break + } + } }