mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-09 19:52:30 +02:00
Graceful shut down server and vips
This commit is contained in:
15
main.go
15
main.go
@@ -4,6 +4,8 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
|
||||
@@ -29,7 +31,16 @@ func main() {
|
||||
MaxHeaderBytes: 1 << 20,
|
||||
}
|
||||
|
||||
log.Printf("Starting server at %s\n", conf.Bind)
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt, os.Kill)
|
||||
|
||||
log.Fatal(s.Serve(netutil.LimitListener(l, conf.MaxClients)))
|
||||
go func() {
|
||||
log.Printf("Starting server at %s\n", conf.Bind)
|
||||
log.Fatal(s.Serve(netutil.LimitListener(l, conf.MaxClients)))
|
||||
}()
|
||||
|
||||
<-stop
|
||||
|
||||
shutdownVips()
|
||||
shutdownServer(s)
|
||||
}
|
||||
|
Reference in New Issue
Block a user