1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-07-04 12:03:43 +02:00

cmd/antelope-api-healtcheck/main.go: in signalEventLoop() no need to wrap the for loop in a anonymous function.

This commit is contained in:
Henrik Hautakoski 2023-02-02 18:19:53 +01:00
parent fba9402584
commit 9456b8acbb
No known key found for this signature in database
GPG key ID: 217490840C18A5D9

View file

@ -96,41 +96,39 @@ func signalEventLoop() {
signal.Notify(sig_ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM) signal.Notify(sig_ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
// Event loop // Event loop
func() { var run bool = true
var run bool = true for run {
for run { // Block until we get a signal.
// Block until we get a signal. sig := <-sig_ch
sig := <-sig_ch
l := logger.New("signal", sig) l := logger.New("signal", sig)
switch sig { switch sig {
case syscall.SIGINT, syscall.SIGTERM: case syscall.SIGINT, syscall.SIGTERM:
l.Info("Program was asked to terminate.") l.Info("Program was asked to terminate.")
run = false run = false
// Tell the server to close. // Tell the server to close.
err := srv.Close() err := srv.Close()
if err != nil { if err != nil {
l.Error("Failed to close server", "error", err) l.Error("Failed to close server", "error", err)
}
// SIGHUP is sent when logfile is rotated.
case syscall.SIGHUP:
msg := "Logfile was rotated: "
if logfd != nil {
setLogFile()
msg += "Filedescriptor was updated"
} else {
msg += "No Filedescriptor to update (most likely uses standard out/err streams)"
}
l.Info(msg)
default:
l.Warn("Unknown signal")
} }
// SIGHUP is sent when logfile is rotated.
case syscall.SIGHUP:
msg := "Logfile was rotated: "
if logfd != nil {
setLogFile()
msg += "Filedescriptor was updated"
} else {
msg += "No Filedescriptor to update (most likely uses standard out/err streams)"
}
l.Info(msg)
default:
l.Warn("Unknown signal")
} }
}() }
} }
// main // main