aboutsummaryrefslogtreecommitdiffstats
path: root/modules/graceful/manager_unix.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-11-15 22:02:46 +0800
committerGitHub <noreply@github.com>2023-11-15 22:02:46 +0800
commit79394b340d227182f94bae48cb08a091c78f2ea2 (patch)
tree48b1c224e95d24b1515b0a80c138b2caf53759cc /modules/graceful/manager_unix.go
parentf65977df3a65e193995c0bdf7069553fd5867fe2 (diff)
downloadgitea-79394b340d227182f94bae48cb08a091c78f2ea2.tar.gz
gitea-79394b340d227182f94bae48cb08a091c78f2ea2.zip
Improve graceful manager code/comment (#28063)
The graceful manager has some bugs (#27643, #28062). This is a preparation for further fixes.
Diffstat (limited to 'modules/graceful/manager_unix.go')
-rw-r--r--modules/graceful/manager_unix.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/graceful/manager_unix.go b/modules/graceful/manager_unix.go
index b1fd6da76d..bdf23a4fde 100644
--- a/modules/graceful/manager_unix.go
+++ b/modules/graceful/manager_unix.go
@@ -107,7 +107,9 @@ func (g *Manager) start(ctx context.Context) {
defer pprof.SetGoroutineLabels(ctx)
// Set the running state & handle signals
- g.setState(stateRunning)
+ if !g.setStateTransition(stateInit, stateRunning) {
+ panic("invalid graceful manager state: transition from init to running failed")
+ }
g.notify(statusMsg("Starting Gitea"))
g.notify(pidMsg())
go g.handleSignals(g.managerCtx)