Documentation ¶
Overview ¶
Zero-downtime restarts in Go.
Index ¶
- Constants
- Variables
- func AwaitSignals(l net.Listener) (err error)
- func Exec(l net.Listener) error
- func ForkExec(l net.Listener) error
- func GetEnvs() (l net.Listener, ppid int, err error)
- func IsErrClosing(err error) bool
- func Kill() error
- func KillParent(ppid int) error
- func Listener() (l net.Listener, err error)
- func Wait(l net.Listener) (syscall.Signal, error)
Constants ¶
const ( // The Single-exec strategy: parent forks child to exec with an inherited // net.Listener; child kills parent and becomes a child of init(8). Single strategy = iota // The Double-exec strategy: parent forks child to exec (first) with an // inherited net.Listener; child signals parent to exec (second); parent // kills child. Double )
const ( SIGINT = syscall.SIGINT SIGQUIT = syscall.SIGQUIT SIGTERM = syscall.SIGTERM SIGUSR2 = syscall.SIGUSR2 )
Don't make the caller import syscall.
Variables ¶
var ( // OnSIGHUP is the function called when the server receives a SIGHUP // signal. The normal use case for SIGHUP is to reload the // configuration. OnSIGHUP func(l net.Listener) error // OnSIGUSR1 is the function called when the server receives a // SIGUSR1 signal. The normal use case for SIGUSR1 is to repon the // log files. OnSIGUSR1 func(l net.Listener) error // The strategy to use; Single by default. Strategy strategy = Single )
Functions ¶
func AwaitSignals ¶
Block this goroutine awaiting signals. Signals are handled as they are by Nginx and Unicorn: <http://unicorn.bogomips.org/SIGNALS.html>.
func GetEnvs ¶
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 IsErrClosing ¶
Test whether an error is equivalent to net.errClosing as returned by Accept during a graceful exit.
func Kill ¶
func Kill() error
Kill process specified in the environment with the signal specified in the environment; default to SIGQUIT.
func KillParent ¶
Send SIGQUIT to the given ppid in order to complete the handoff to the child process.
Types ¶
This section is empty.