forked from forgejo/forgejo
Graceful fixes (#8645)
* Only attempt to kill parent once * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Add waitgroup for running servers
This commit is contained in:
parent
7d1a7c05db
commit
f067e12859
5 changed files with 35 additions and 7 deletions
|
@ -12,8 +12,24 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var killParent sync.Once
|
||||
|
||||
// KillParent sends the kill signal to the parent process if we are a child
|
||||
func KillParent() {
|
||||
killParent.Do(func() {
|
||||
if IsChild {
|
||||
ppid := syscall.Getppid()
|
||||
if ppid > 1 {
|
||||
_ = syscall.Kill(ppid, syscall.SIGTERM)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// RestartProcess starts a new process passing it the active listeners. It
|
||||
// doesn't fork, but starts a new process using the same environment and
|
||||
// arguments as when it was originally started. This allows for a newly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue