fix image.Service termination in case Submit was never called
This commit is contained in:
committed by
Umputun
parent
97d7467033
commit
449e375cbb
+14
-12
@@ -480,18 +480,6 @@ func (a *serverApp) run(ctx context.Context) error {
|
||||
<-ctx.Done()
|
||||
log.Print("[INFO] shutdown initiated")
|
||||
a.restSrv.Shutdown()
|
||||
if a.devAuth != nil {
|
||||
a.devAuth.Shutdown()
|
||||
}
|
||||
if e := a.dataService.Close(); e != nil {
|
||||
log.Printf("[WARN] failed to close data store, %s", e)
|
||||
}
|
||||
if e := a.avatarStore.Close(); e != nil {
|
||||
log.Printf("[WARN] failed to close avatar store, %s", e)
|
||||
}
|
||||
a.notifyService.Close()
|
||||
a.imageService.Close()
|
||||
log.Print("[INFO] shutdown completed")
|
||||
}()
|
||||
|
||||
a.activateBackup(ctx) // runs in goroutine for each site
|
||||
@@ -502,6 +490,20 @@ func (a *serverApp) run(ctx context.Context) error {
|
||||
go a.imageService.Cleanup(ctx) // pictures cleanup for staging images
|
||||
|
||||
a.restSrv.Run(a.Port)
|
||||
|
||||
// shutdown procedures after HTTP server is stopped
|
||||
if a.devAuth != nil {
|
||||
a.devAuth.Shutdown()
|
||||
}
|
||||
if e := a.dataService.Close(); e != nil {
|
||||
log.Printf("[WARN] failed to close data store, %s", e)
|
||||
}
|
||||
if e := a.avatarStore.Close(); e != nil {
|
||||
log.Printf("[WARN] failed to close avatar store, %s", e)
|
||||
}
|
||||
a.notifyService.Close()
|
||||
a.imageService.Close()
|
||||
|
||||
close(a.terminated)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user