Reopen log files after receiving a SIGHUP signal (#13112)

* Reopen log files after receiving a SIGHUP signal

Implements a system signals listener in log.FileLogWriter.

After receiving a SIGHUP signal from the system, the listener will close the current log file and then open it again.

The listener will finishes after receiving a SIGINT, SIGKILL or SIGTERM signal.

Closes grafana/grafana#2497

* Move the SIGHUP handling to the main file
This commit is contained in:
maicon
2018-09-04 10:31:41 +02:00
committed by Torkel Ödegaard
parent dac2c62545
commit a6aa219895
4 changed files with 39 additions and 5 deletions
+9 -5
View File
@@ -96,13 +96,17 @@ func main() {
func listenToSystemSignals(server *GrafanaServerImpl) {
signalChan := make(chan os.Signal, 1)
ignoreChan := make(chan os.Signal, 1)
sighupChan := make(chan os.Signal, 1)
signal.Notify(ignoreChan, syscall.SIGHUP)
signal.Notify(sighupChan, syscall.SIGHUP)
signal.Notify(signalChan, os.Interrupt, os.Kill, syscall.SIGTERM)
select {
case sig := <-signalChan:
server.Shutdown(fmt.Sprintf("System signal: %s", sig))
for {
select {
case _ = <-sighupChan:
log.Reload()
case sig := <-signalChan:
server.Shutdown(fmt.Sprintf("System signal: %s", sig))
}
}
}