Categorygithub.com/rcrowley/goagain
modulepackage
0.0.0-20140424170347-f2f192b5d1a9
Repository: https://github.com/rcrowley/goagain.git
Documentation: pkg.go.dev

# README

goagain

Zero-downtime restarts in Go

The goagain package provides primitives for bringing zero-downtime restarts to Go applications that accept connections from a net.TCPListener or net.UnixListener.

Have a look at the examples because it isn't just a matter of importing the library and everything working. Your main function will have to accomodate the goagain protocols and your process will have to have some definition (however contrived you like) of a graceful shutdown process.

Installation

go get github.com/rcrowley/goagain

Usage

Send SIGUSR2 to a process using goagain and it will restart without downtime.

example/single/main.go: The Single strategy (named because it calls execve(2) once) operates similarly to Nginx and Unicorn. The parent forks a child, the child execs, and then the child kills the parent. This is easy to understand but doesn't play nicely with Upstart and similar direct-supervision init(8) daemons. It should play nicely with systemd.

example/double/main.go: The Double strategy (named because it calls execve(2) twice) is experimental so proceed with caution. The parent forks a child, the child execs, the child signals the parent, the parent execs, and finally the parent kills the child. This is regrettably much more complicated but plays nicely with Upstart and similar direct-supervision init(8) daemons.

# Packages

No description provided by the author

# Functions

Block this goroutine awaiting signals.
Re-exec this same image without dropping the net.Listener.
Fork and exec this same image without dropping the net.Listener.
Convert and validate the GOAGAIN_FD, GOAGAIN_NAME, and GOAGAIN_PPID environment variables.
Test whether an error is equivalent to net.errClosing as returned by Accept during a graceful exit.
Kill process specified in the environment with the signal specified in the environment; default to SIGQUIT.
Send SIGQUIT to the given ppid in order to complete the handoff to the child process.
Reconstruct a net.Listener from a file descriptior and name specified in the environment.
Block this goroutine awaiting signals.

# Constants

The Double-exec strategy: parent forks child to exec (first) with an inherited net.Listener; child signals parent to exec (second); parent kills child.
Don't make the caller import syscall.
Don't make the caller import syscall.
Don't make the caller import syscall.
Don't make the caller import syscall.
The Single-exec strategy: parent forks child to exec with an inherited net.Listener; child kills parent and becomes a child of init(8).

# Variables

OnSIGHUP is the function called when the server receives a SIGHUP signal.
OnSIGUSR1 is the function called when the server receives a SIGUSR1 signal.
The strategy to use; Single by default.