comments
This commit is contained in:
parent
f5295e5b81
commit
60b34bd164
8
grace.go
8
grace.go
@ -205,6 +205,8 @@ func Restart(listeners []Listener) (err error) {
|
|||||||
if len(listeners) == 0 {
|
if len(listeners) == 0 {
|
||||||
return errors.New("restart must be given listeners.")
|
return errors.New("restart must be given listeners.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract the fds from the listeners.
|
||||||
files := make([]*os.File, len(listeners))
|
files := make([]*os.File, len(listeners))
|
||||||
for i, l := range listeners {
|
for i, l := range listeners {
|
||||||
files[i], err = l.File()
|
files[i], err = l.File()
|
||||||
@ -214,15 +216,21 @@ func Restart(listeners []Listener) (err error) {
|
|||||||
defer files[i].Close()
|
defer files[i].Close()
|
||||||
syscall.CloseOnExec(int(files[i].Fd()))
|
syscall.CloseOnExec(int(files[i].Fd()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the original binary location. This works with symlinks such that if
|
||||||
|
// the file it points to has been changed we will use the updated symlink.
|
||||||
argv0, err := exec.LookPath(os.Args[0])
|
argv0, err := exec.LookPath(os.Args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In order to keep the working directory the same as when we started.
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pass on the environment and replace the old count key with the new one.
|
||||||
var env []string
|
var env []string
|
||||||
for _, v := range os.Environ() {
|
for _, v := range os.Environ() {
|
||||||
if !strings.HasPrefix(v, envCountKeyPrefix) {
|
if !strings.HasPrefix(v, envCountKeyPrefix) {
|
||||||
|
Loading…
Reference in New Issue
Block a user