Skip to content

Commit bec5662

Browse files
authored
Immediately Hammer if second kill is sent (#18823) (#18826)
Backport #18823 Currently Gitea will wait for HammerTime or nice shutdown if kill -1 or kill -2 is sent. We should just immediately hammer if there is a second kill. Signed-off-by: Andrew Thornton <[email protected]>
1 parent fa9be55 commit bec5662

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

modules/graceful/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ func (g *Manager) RunAtHammer(hammer func()) {
192192
}
193193
func (g *Manager) doShutdown() {
194194
if !g.setStateTransition(stateRunning, stateShuttingDown) {
195+
g.DoImmediateHammer()
195196
return
196197
}
197198
g.lock.Lock()

modules/graceful/manager_unix.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ func (g *Manager) DoGracefulRestart() {
168168
if setting.GracefulRestartable {
169169
log.Info("PID: %d. Forking...", os.Getpid())
170170
err := g.doFork()
171-
if err != nil && err.Error() != "another process already forked. Ignoring this one" {
172-
log.Error("Error whilst forking from PID: %d : %v", os.Getpid(), err)
171+
if err != nil {
172+
if err.Error() == "another process already forked. Ignoring this one" {
173+
g.DoImmediateHammer()
174+
} else {
175+
log.Error("Error whilst forking from PID: %d : %v", os.Getpid(), err)
176+
}
173177
}
174178
} else {
175179
log.Info("PID: %d. Not set restartable. Shutting down...", os.Getpid())

0 commit comments

Comments
 (0)