bootstrap

package
v1.59.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

func New(pidFile string, upgradesEnabled bool) (*Bootstrap, error)

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

func (*Bootstrap) RegisterStarter

func (b *Bootstrap) RegisterStarter(starter Starter)

RegisterStarter adds a new starter

func (*Bootstrap) Start

func (b *Bootstrap) Start() error

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

func (*Bootstrap) Wait

func (b *Bootstrap) Wait() error

Wait will signal process readiness to the parent and than wait for an exit condition SIGTERM, SIGINT and a runtime error will trigger an immediate shutdown in case of an upgrade there will be a grace period to complete the ongoing requests

type GracefulStoppableServer

type GracefulStoppableServer interface {
	GracefulStop()
	Stop()
	Serve(l net.Listener, secure bool) error
}

GracefulStoppableServer allows to serve contents on a net.Listener, Stop serving and performing a GracefulStop

func NewServerFactory

func NewServerFactory() (GracefulStoppableServer, error)

NewServerFactory initializes a rubyserver and then lazily initializes both secure and insecure grpc.Server

type ListenFunc

type ListenFunc func(net, addr string) (net.Listener, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL