1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-18 05:00:03 +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
import (
@ -87,16 +86,18 @@ func signalEventLoop() {
// Block until we get a signal.
sig := <- sig_ch
l := logger.New("signal", sig)
switch sig {
case syscall.SIGINT :
logger.Info("Interrupted")
l.Info("Interrupted")
run = false
case syscall.SIGTERM :
logger.Info("Program was asked to terminate.", "signal", "SIGTERM")
l.Info("Program was asked to terminate.")
run = false
// SIGHUP is sent when logfile is rotated.
case syscall.SIGHUP :
msg := "SIGHUP (Logfile was rotated): "
msg := "Logfile was rotated: "
if logfd != nil {
setLogFile()
@ -105,9 +106,9 @@ func signalEventLoop() {
msg += "No Filedescriptor to update (most likely uses standard out/err streams)"
}
logger.Info(msg)
l.Info(msg)
default:
logger.Warn("Unknown signal", "signal", sig)
l.Warn("Unknown signal")
}
}
}()