func listenForSignalHangup()

in log/initialization.go [65:83]


func listenForSignalHangup(l reopen.Reopener, isMainLogger bool, logFilePath string, sighup chan os.Signal) {
	for v := range sighup {
		// Specifically, do _not_ write to the log that is being reopened,
		// but log this to the _main_ log file instead as the actual log
		// might be specialised, eg: an access logger leading to an incorrect entry
		logger.WithFields(logrus.Fields{"signal": v, "path": logFilePath}).Print("Reopening log file on signal")

		err := l.Reopen()
		if err != nil {
			if isMainLogger {
				// Main logger failed to reopen, last ditch effort to notify the user, but don't
				// do this for auxiliary loggers, since we may get double-logs
				log.Printf("Unable to reopen log file '%s' after %v. Error %v", logFilePath, v, err)
			} else {
				logger.WithError(err).WithFields(logrus.Fields{"signal": v, "path": logFilePath}).Print("Failed to reopen log file")
			}
		}
	}
}