Add addtional closeSignal chan for program to wait for.
This commit is contained in:
parent
0c05ffeef6
commit
ddaf2bb991
@ -107,13 +107,16 @@ 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)
|
||||||
|
|
||||||
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-doneSignal:
|
case <-doneSignal:
|
||||||
if err := srv.Stop(); err != nil {
|
if err := srv.Stop(); err != nil {
|
||||||
logErr.Fatalln(err)
|
logErr.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
closeSignal <- true
|
||||||
case <-uploadDirNotify:
|
case <-uploadDirNotify:
|
||||||
sz, err := utils.DirectorySize(config.Uploads.Directory)
|
sz, err := utils.DirectorySize(config.Uploads.Directory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -125,5 +128,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-closeSignal
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user