-
Notifications
You must be signed in to change notification settings - Fork 144
/
legacy.go
32 lines (28 loc) · 831 Bytes
/
legacy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package goagain
import (
"fmt"
"net"
"os"
"syscall"
)
// Block this goroutine awaiting signals. Signals are handled as they
// are by Nginx and Unicorn: <http://unicorn.bogomips.org/SIGNALS.html>.
func AwaitSignals(l net.Listener) (err error) {
_, err = Wait(l)
return
}
// Convert and validate the GOAGAIN_FD, GOAGAIN_NAME, and GOAGAIN_PPID
// environment variables. If all three are present and in order, this
// is a child process that may pick up where the parent left off.
func GetEnvs() (l net.Listener, ppid int, err error) {
if _, err = fmt.Sscan(os.Getenv("GOAGAIN_PPID"), &ppid); nil != err {
return
}
l, err = Listener()
return
}
// Send SIGQUIT to the given ppid in order to complete the handoff to the
// child process.
func KillParent(ppid int) error {
return syscall.Kill(ppid, syscall.SIGQUIT)
}