Skip to content

Commit 83c9035

Browse files
authored
Immediately Hammer if second kill is sent (#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 4b3ebda commit 83c9035

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
@@ -193,6 +193,7 @@ func (g *Manager) RunAtHammer(hammer func()) {
193193

194194
func (g *Manager) doShutdown() {
195195
if !g.setStateTransition(stateRunning, stateShuttingDown) {
196+
g.DoImmediateHammer()
196197
return
197198
}
198199
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)