1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-11-29 23:07:40 +02:00

Get rid of os.Exit

This commit is contained in:
DarthSim
2020-02-27 21:44:59 +06:00
parent 5d3b8f19fc
commit 8e3cf54d85
14 changed files with 225 additions and 109 deletions

View File

@@ -31,10 +31,10 @@ func buildRouter() *router {
return r
}
func startServer() *http.Server {
func startServer(cancel context.CancelFunc) (*http.Server, error) {
l, err := listenReuseport(conf.Network, conf.Bind)
if err != nil {
logFatal(err.Error())
return nil, fmt.Errorf("Can't start server: %s", err)
}
l = netutil.LimitListener(l, conf.MaxClients)
@@ -50,16 +50,19 @@ func startServer() *http.Server {
s.SetKeepAlivesEnabled(false)
}
initProcessingHandler()
if err := initProcessingHandler(); err != nil {
return nil, err
}
go func() {
logNotice("Starting server at %s", conf.Bind)
if err := s.Serve(l); err != nil && err != http.ErrServerClosed {
logFatal(err.Error())
logError(err.Error())
}
cancel()
}()
return s
return s, nil
}
func shutdownServer(s *http.Server) {