if socket-activated, exit after printing

This commit is contained in:
Jonas Große Sundrup 2023-12-29 22:09:22 +01:00
parent 1edb189aba
commit ba1798ce46
No known key found for this signature in database
GPG key ID: 5B587ADC0531D442

View file

@ -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
}
}
}