Documentation ¶
Index ¶
Constants ¶
const ( // EnvPidFile is the name of the environment variable containing the pid file path EnvPidFile = "GITALY_PID_FILE" // EnvUpgradesEnabled is an environment variable that when defined gitaly must enable graceful upgrades on SIGHUP EnvUpgradesEnabled = "GITALY_UPGRADES_ENABLED" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶
type Bootstrap struct { // StopAction will be invoked during a graceful stop. It must wait until the shutdown is completed StopAction func() // contains filtered or unexported fields }
Bootstrap handles graceful upgrades
func New ¶
New performs tableflip initialization
pidFile is optional, if provided it will always contain the current process PID upgradesEnabled controls the upgrade process on SIGHUP signal
first boot: * gitaly starts as usual, we will refer to it as p1 * New will build a tableflip.Upgrader, we will refer to it as upg * sockets and files must be opened with upg.Fds * p1 will trap SIGHUP and invoke upg.Upgrade() * when ready to accept incoming connections p1 will call upg.Ready() * upg.Exit() channel will be closed when an upgrades completed successfully and the process must terminate
graceful upgrade:
- user replaces gitaly binary and/or config file
- user sends SIGHUP to p1
- p1 will fork and exec the new gitaly, we will refer to it as p2
- from now on p1 will ignore other SIGHUP
- if p2 terminates with a non-zero exit code, SIGHUP handling will be restored
- p2 will follow the "first boot" sequence but upg.Fds will provide sockets and files from p1, when available
- when p2 invokes upg.Ready() all the shared file descriptors not claimed by p2 will be closed
- upg.Exit() channel in p1 will be closed now and p1 can gracefully terminate already accepted connections
- upgrades cannot starts again if p1 and p2 are both running, an hard termination should be scheduled to overcome freezes during a graceful shutdown
gitaly-wrapper is supposed to set EnvUpgradesEnabled in order to enable graceful upgrades
func (*Bootstrap) RegisterStarter ¶
RegisterStarter adds a new starter
func (*Bootstrap) Start ¶
Start will invoke all the registered starters and wait asynchronously for runtime errors in case a Starter fails then the error is returned and the function is aborted
type ListenFunc ¶
ListenFunc is a net.Listener factory
type Starter ¶
type Starter func(ListenFunc, chan<- error) error
Starter is function to initialize a net.Listener it receives a ListenFunc to be used for net.Listener creation and a chan<- error to signal runtime errors It must serve incoming connections asynchronously and signal errors on the channel the return value is for setup errors