Documentation
¶
Index ¶
- func DoUpgrade(cfg *Config, info *UpgradeInfo) error
- func DownloadBinary(cfg *Config, info *UpgradeInfo) error
- func EnsureBinary(path string) error
- func GetDownloadURL(info *UpgradeInfo) (string, error)
- func LaunchProcess(cfg *Config, args []string, stdout, stderr io.Writer) (bool, error)
- func MarkExecutable(path string) error
- func Run(args []string) error
- type Config
- func (cfg *Config) CurrentBin() (string, error)
- func (cfg *Config) GenesisBin() string
- func (cfg *Config) Root() string
- func (cfg *Config) SetCurrentUpgrade(upgradeName string) error
- func (cfg *Config) SymLinkToGenesis() (string, error)
- func (cfg *Config) UpgradeBin(upgradeName string) string
- func (cfg *Config) UpgradeDir(upgradeName string) string
- type UpgradeConfig
- type UpgradeInfo
- type WaitResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoUpgrade ¶
func DoUpgrade(cfg *Config, info *UpgradeInfo) error
DoUpgrade will be called after the log message has been parsed and the process has terminated. We can now make any changes to the underlying directory without interference and leave it in a state, so we can make a proper restart
func DownloadBinary ¶
func DownloadBinary(cfg *Config, info *UpgradeInfo) error
DownloadBinary will grab the binary and place it in the proper directory
func EnsureBinary ¶
EnsureBinary ensures the file exists and is executable, or returns an error
func GetDownloadURL ¶
func GetDownloadURL(info *UpgradeInfo) (string, error)
GetDownloadURL will check if there is an arch-dependent binary specified in Info
func LaunchProcess ¶
LaunchProcess runs a subprocess and returns when the subprocess exits, either when it dies, or *after* a successful upgrade.
func MarkExecutable ¶
MarkExecutable will try to set the executable bits if not already set Fails if file doesn't exist or we cannot set those bits
Types ¶
type Config ¶
Config is the information passed in to control the daemon
func GetConfigFromEnv ¶
GetConfigFromEnv will read the environmental variables into a config and then validate it is reasonable
func (*Config) CurrentBin ¶
CurrentBin is the path to the currently selected binary (genesis if no link is set) This will resolve the symlink to the underlying directory to make it easier to debug
func (*Config) GenesisBin ¶
GenesisBin is the path to the genesis binary - must be in place to start manager
func (*Config) SetCurrentUpgrade ¶
SetCurrentUpgrade sets the named upgrade to be the current link, returns error if this binary doesn't exist
func (*Config) SymLinkToGenesis ¶
Symlink to genesis
func (*Config) UpgradeBin ¶
UpgradeBin is the path to the binary for the named upgrade
func (*Config) UpgradeDir ¶
UpgradeDir is the directory named upgrade
type UpgradeConfig ¶
UpgradeConfig is expected format for the info field to allow auto-download
type UpgradeInfo ¶
type UpgradeInfo struct { Name string // Only 1 of Height or Time is non-zero value Height int Time string Info string }
UpgradeInfo is the details from the regexp
func WaitForUpdate ¶
func WaitForUpdate(scanner *bufio.Scanner) (*UpgradeInfo, error)
WaitForUpdate will listen to the scanner until a line matches upgradeRegexp. It returns (info, nil) on a matching line It returns (nil, err) if the input stream errored It returns (nil, nil) if the input closed without ever matching the regexp
func WaitForUpgradeOrExit ¶
WaitForUpgradeOrExit listens to both output streams of the process, as well as the process state itself When it returns, the process is finished and all streams have closed.
It returns (info, nil) if an upgrade should be initiated (and we killed the process) It returns (nil, err) if the process died by itself, or there was an issue reading the pipes It returns (nil, nil) if the process exited normally without triggering an upgrade. This is very unlikely to happend with "start" but may happend with short-lived commands like `gaiad export ...`
type WaitResult ¶
type WaitResult struct {
// contains filtered or unexported fields
}
WaitResult is used to wrap feedback on cmd state with some mutex logic. This is needed as multiple go-routines can affect this - two read pipes that can trigger upgrade As well as the command, which can fail
func (*WaitResult) AsResult ¶
func (u *WaitResult) AsResult() (*UpgradeInfo, error)
AsResult reads the data protected by mutex to avoid race conditions
func (*WaitResult) SetError ¶
func (u *WaitResult) SetError(myErr error)
SetError will set with the first error using a mutex don't set it once info is set, that means we chose to kill the process
func (*WaitResult) SetUpgrade ¶
func (u *WaitResult) SetUpgrade(up *UpgradeInfo)
SetUpgrade sets first non-nil upgrade info, ensure error is then nil pass in a command to shutdown on successful upgrade