diff options
Diffstat (limited to 'modules/graceful/restart.go')
-rw-r--r-- | modules/graceful/restart.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/graceful/restart.go b/modules/graceful/restart.go index 5cba0581a5..04ee072c80 100644 --- a/modules/graceful/restart.go +++ b/modules/graceful/restart.go @@ -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 |