Restart process should use the current process' pid (#7373)

This fixes varying pids for server-respawns. And avoids duplicate process
creating multiple pids when the server restart signal is triggered with
service restart enabled.

Fixes #7350
master
Praveen raj Mani 6 years ago committed by kannappanr
parent 8e1e701d35
commit 89e45d0695
  1. 9
      cmd/service.go

@ -19,6 +19,7 @@ package cmd
import ( import (
"os" "os"
"os/exec" "os/exec"
"syscall"
) )
// Type of service signals currently supported. // Type of service signals currently supported.
@ -56,9 +57,7 @@ func restartProcess() error {
return err return err
} }
// Pass on the environment and replace the old count key with the new one. // Invokes the execve system call.
cmd := exec.Command(argv0, os.Args[1:]...) // Re-uses the same pid. This preserves the pid over multiple server-respawns.
cmd.Stdout = os.Stdout return syscall.Exec(argv0, os.Args, os.Environ())
cmd.Stderr = os.Stderr
return cmd.Start()
} }

Loading…
Cancel
Save