1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

don't fire ErrServerClosed on manually interrupt signals (CTRL/CMD+C)

Former-commit-id: 673c84dd13bb99c0926aa1b4a6b4eff9745403d8
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-04-28 05:22:58 +03:00
parent 27ca1c93f5
commit b657c5e6af
44 changed files with 101 additions and 110 deletions

View File

@@ -6,6 +6,7 @@ package host
// supervisor.
import (
"context"
"errors"
"fmt"
"io"
"net/http"
@@ -27,8 +28,9 @@ func WriteStartupLogOnServe(w io.Writer) func(TaskHost) {
if runtime.GOOS == "darwin" {
interruptkey = "CMD"
}
_, _ = w.Write([]byte(fmt.Sprintf("Now listening on: %s\nApplication started. Press %s+C to shut down.\n",
listeningURI, interruptkey)))
_, _ = fmt.Fprintf(w, "Now listening on: %s\nApplication started. Press %s+C to shut down.\n",
listeningURI, interruptkey)
}
}
@@ -38,7 +40,7 @@ func ShutdownOnInterrupt(su *Supervisor, shutdownTimeout time.Duration) func() {
return func() {
ctx, cancel := context.WithTimeout(context.TODO(), shutdownTimeout)
defer cancel()
su.Shutdown(ctx)
su.shutdownOnInterrupt(ctx)
su.RestoreFlow()
}
}
@@ -58,9 +60,9 @@ func (h TaskHost) Serve() error {
return err
}
// if http.serverclosed ignroe the error, it will have this error
// if http.serverclosed ignore the error, it will have this error
// from the previous close
if err := h.Supervisor.Server.Serve(l); err != http.ErrServerClosed {
if err := h.Supervisor.Server.Serve(l); !errors.Is(err, http.ErrServerClosed) {
return err
}
return nil