Browse Source

defer shutdown

DarthSim 5 years ago
parent
commit
ed3ddbd710
1 changed files with 2 additions and 3 deletions
  1. 2 3
      main.go

+ 2 - 3
main.go

@@ -32,6 +32,7 @@ func initialize() {
 
 func main() {
 	initialize()
+	defer shutdownVips()
 
 	go func() {
 		var logMemStats = len(os.Getenv("IMGPROXY_LOG_MEM_STATS")) > 0
@@ -48,12 +49,10 @@ func main() {
 	}()
 
 	s := startServer()
+	defer shutdownServer(s)
 
 	stop := make(chan os.Signal, 1)
 	signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
 
 	<-stop
-
-	shutdownServer(s)
-	shutdownVips()
 }