fix: do not os.Exit(1) while writing goroutines during shutdown (#17640)

Also shutdown poll add jitter, to verify if the shutdown
sequence can finish before 500ms, this reduces the overall
time taken during "restart" of the service.

Provides speedup for `mc admin service restart` during
active I/O, also ensures that systemd doesn't treat the
returned 'error' as a failure, certain configurations in
systemd can cause it to 'auto-restart' the process by-itself
which can interfere with `mc admin service restart`.

It can be observed how now restarting the service is
much snappier.
This commit is contained in:
Harshavardhana
2023-07-12 07:18:30 -07:00
committed by GitHub
parent a566bcf613
commit 2d1cda2061
2 changed files with 28 additions and 12 deletions

View File

@@ -46,21 +46,17 @@ func handleSignals() {
}
stopProcess := func() bool {
var err, oerr error
// send signal to various go-routines that they need to quit.
cancelGlobalContext()
if httpServer := newHTTPServerFn(); httpServer != nil {
err = httpServer.Shutdown()
if !errors.Is(err, http.ErrServerClosed) {
if err := httpServer.Shutdown(); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.LogIf(context.Background(), err)
}
}
if objAPI := newObjectLayerFn(); objAPI != nil {
oerr = objAPI.Shutdown(context.Background())
logger.LogIf(context.Background(), oerr)
logger.LogIf(context.Background(), objAPI.Shutdown(context.Background()))
}
if srv := newConsoleServerFn(); srv != nil {
@@ -71,7 +67,7 @@ func handleSignals() {
globalEventNotifier.RemoveAllBucketTargets()
}
return (err == nil && oerr == nil)
return true
}
for {