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

src/main.go: in eventLoop() create a child logger with a signal parameter and use that to log messages.

This commit is contained in:
Henrik Hautakoski 2022-08-21 14:59:44 +02:00
parent 8b86a5d34b
commit bd412bb0eb
No known key found for this signature in database
GPG key ID: 608414D93E862CCD

View file

@ -1,4 +1,3 @@
package main package main
import ( import (
@ -87,16 +86,18 @@ func signalEventLoop() {
// Block until we get a signal. // Block until we get a signal.
sig := <- sig_ch sig := <- sig_ch
l := logger.New("signal", sig)
switch sig { switch sig {
case syscall.SIGINT : case syscall.SIGINT :
logger.Info("Interrupted") l.Info("Interrupted")
run = false run = false
case syscall.SIGTERM : case syscall.SIGTERM :
logger.Info("Program was asked to terminate.", "signal", "SIGTERM") l.Info("Program was asked to terminate.")
run = false run = false
// SIGHUP is sent when logfile is rotated. // SIGHUP is sent when logfile is rotated.
case syscall.SIGHUP : case syscall.SIGHUP :
msg := "SIGHUP (Logfile was rotated): " msg := "Logfile was rotated: "
if logfd != nil { if logfd != nil {
setLogFile() setLogFile()
@ -105,9 +106,9 @@ func signalEventLoop() {
msg += "No Filedescriptor to update (most likely uses standard out/err streams)" msg += "No Filedescriptor to update (most likely uses standard out/err streams)"
} }
logger.Info(msg) l.Info(msg)
default: default:
logger.Warn("Unknown signal", "signal", sig) l.Warn("Unknown signal")
} }
} }
}() }()