mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-22 07:30:25 +00:00
0056984d4b
Log file can be rotated sending a SIGUSR1 signal on Unix based systems and using "sftpgo service rotatelogs" on Windows Fixes #133
25 lines
445 B
Go
25 lines
445 B
Go
// +build !windows
|
|
|
|
package service
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/drakkan/sftpgo/logger"
|
|
)
|
|
|
|
func registerSigUSR1() {
|
|
sig := make(chan os.Signal, 1)
|
|
signal.Notify(sig, syscall.SIGUSR1)
|
|
go func() {
|
|
for range sig {
|
|
logger.Debug(logSender, "", "Received log file rotation request")
|
|
err := logger.RotateLogFile()
|
|
if err != nil {
|
|
logger.Warn(logSender, "", "error rotating log file: %v", err)
|
|
}
|
|
}
|
|
}()
|
|
}
|