Added SIGHUP handler to reopen logs. Removed closeSingal, and doneSignal moved to the bottom of main().
This commit is contained in:
parent
bf189d050a
commit
1c8beb69ce
@ -93,17 +93,16 @@ func main() {
|
||||
|
||||
doneSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||
closeSignal := make(chan bool, 1)
|
||||
logReopenSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(logReopenSignal, syscall.SIGHUP)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-doneSignal:
|
||||
if err := srv.Stop(); err != nil {
|
||||
logErr.Fatalln("failed to properly shutdown a server:", err)
|
||||
}
|
||||
|
||||
closeSignal <- true
|
||||
case <-logReopenSignal:
|
||||
logErr.Reopen(config.Log.Error)
|
||||
logUpload.Reopen(config.Log.Upload)
|
||||
logDownload.Reopen(config.Log.Download)
|
||||
case <-uploadDirNotify:
|
||||
sz, err := utils.DirectorySize(config.Uploads.Directory)
|
||||
if err != nil {
|
||||
@ -117,5 +116,9 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
<-closeSignal
|
||||
<-doneSignal
|
||||
|
||||
if err := srv.Stop(); err != nil {
|
||||
logErr.Fatalln("failed to properly shutdown a server:", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user