mirror of https://github.com/go-gitea/gitea.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.5 KiB
36 lines
1.5 KiB
// Copyright 2019 The Gitea Authors. All rights reserved. |
|
// SPDX-License-Identifier: MIT |
|
|
|
package graceful |
|
|
|
import ( |
|
"context" |
|
) |
|
|
|
// Shutdown procedure: |
|
// * cancel ShutdownContext: the registered context consumers have time to do their cleanup (they could use the hammer context) |
|
// * cancel HammerContext: the all context consumers have limited time to do their cleanup (wait for a few seconds) |
|
// * cancel TerminateContext: the registered context consumers have time to do their cleanup (but they shouldn't use shutdown/hammer context anymore) |
|
// * cancel manager context |
|
// If the shutdown is triggered again during the shutdown procedure, the hammer context will be canceled immediately to force to shut down. |
|
|
|
// ShutdownContext returns a context.Context that is Done at shutdown |
|
// Callers using this context should ensure that they are registered as a running server |
|
// in order that they are waited for. |
|
func (g *Manager) ShutdownContext() context.Context { |
|
return g.shutdownCtx |
|
} |
|
|
|
// HammerContext returns a context.Context that is Done at hammer |
|
// Callers using this context should ensure that they are registered as a running server |
|
// in order that they are waited for. |
|
func (g *Manager) HammerContext() context.Context { |
|
return g.hammerCtx |
|
} |
|
|
|
// TerminateContext returns a context.Context that is Done at terminate |
|
// Callers using this context should ensure that they are registered as a terminating server |
|
// in order that they are waited for. |
|
func (g *Manager) TerminateContext() context.Context { |
|
return g.terminateCtx |
|
}
|
|
|