1
0
Fork 0
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:
zeripath 2019-10-23 16:32:19 +01:00 committed by GitHub
parent 7d1a7c05db
commit f067e12859
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 7 deletions

View file

@ -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