Commit b0fa9575 authored by ale's avatar ale
Browse files

Properly stop the server on SIGTERM

parent c1705718
Pipeline #418 passed with stages
in 1 minute and 18 seconds
......@@ -215,10 +215,10 @@ func (c *serverCommand) run(ctx context.Context) error {
return err
}
return c.runServer(app)
return c.runServer(ctx, app)
}
func (c *serverCommand) runServer(app *idpapp.App) error {
func (c *serverCommand) runServer(ctx context.Context, app *idpapp.App) error {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(c.staticDir))))
http.Handle("/metrics", promhttp.Handler())
http.Handle("/", app.HTTPHandler())
......@@ -227,6 +227,13 @@ func (c *serverCommand) runServer(app *idpapp.App) error {
s := &http.Server{
Addr: c.addr,
}
// Stop it when the context is canceled.
go func() {
<-ctx.Done()
s.Close()
}()
var lerr error
if c.sslCert != "" && c.sslKey != "" {
cert, err := tls.LoadX509KeyPair(c.sslCert, c.sslKey)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment