1
0

Add addtional closeSignal chan for program to wait for.

This commit is contained in:
Alexander Andreev 2022-02-08 02:05:38 +04:00
parent 0c05ffeef6
commit ddaf2bb991
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -107,23 +107,29 @@ func main() {
doneSignal := make(chan os.Signal, 1) doneSignal := make(chan os.Signal, 1)
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
closeSignal := make(chan bool, 1)
for { go func() {
select { for {
case <-doneSignal: select {
if err := srv.Stop(); err != nil { case <-doneSignal:
logErr.Fatalln(err) if err := srv.Stop(); err != nil {
} logErr.Fatalln(err)
case <-uploadDirNotify: }
sz, err := utils.DirectorySize(config.Uploads.Directory) closeSignal <- true
if err != nil { case <-uploadDirNotify:
logErr.Println(err) sz, err := utils.DirectorySize(config.Uploads.Directory)
} if err != nil {
logErr.Println(err)
}
if sz > 0 { if sz > 0 {
uploadDirSize = sz uploadDirSize = sz
}
} }
} }
} }()
<-closeSignal
} }