mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-11-29 22:08:10 +02:00
Allow to rotate logs on demand
Log file can be rotated sending a SIGUSR1 signal on Unix based systems and using "sftpgo service rotatelogs" on Windows Fixes #133
This commit is contained in:
25
service/sigusr1_unix.go
Normal file
25
service/sigusr1_unix.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// +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)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user