Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding zerolog logging to cosmovisor #10217

Merged
merged 14 commits into from
Sep 28, 2021
Merged
Prev Previous commit
Next Next commit
fixing formatting
  • Loading branch information
spoo-bar committed Sep 23, 2021
commit aea872a74f025307368f76184e8ab98b7d996278
2 changes: 1 addition & 1 deletion cosmovisor/cmd/cosmovisor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Run(args []string) error {
doUpgrade, err := launcher.Run(args, os.Stdout, os.Stderr)
// if RestartAfterUpgrade, we launch after a successful upgrade (only condition LaunchProcess returns nil)
for cfg.RestartAfterUpgrade && err == nil && doUpgrade {
cosmovisor.Logger.Info().Msgf("[cosmovisor] upgrade detected, relaunching the app ", cfg.Name)
cosmovisor.Logger.Info().Msgf("[cosmovisor] upgrade detected, relaunching the app %s", cfg.Name)
doUpgrade, err = launcher.Run(args, os.Stdout, os.Stderr)
}
if doUpgrade && err == nil {
Expand Down
8 changes: 4 additions & 4 deletions cosmovisor/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (l Launcher) WaitForUpgradeOrExit(cmd *exec.Cmd) (bool, error) {
select {
case <-l.fw.MonitorUpdate(currentUpgrade):
// upgrade - kill the process and restart
Logger.Info().Msgf("[cosmovisor] Daemon shutting down in an attempt to restart")
Logger.Info().Msg("[cosmovisor] Daemon shutting down in an attempt to restart")
_ = cmd.Process.Kill()
case err := <-cmdDone:
l.fw.Stop()
Expand Down Expand Up @@ -160,18 +160,18 @@ func doPreUpgrade(cfg *Config) error {

if err != nil {
if err.(*exec.ExitError).ProcessState.ExitCode() == 1 {
Logger.Info().Msgf("pre-upgrade command does not exist. continuing the upgrade.")
Logger.Info().Msg("pre-upgrade command does not exist. continuing the upgrade.")
return nil
}
if err.(*exec.ExitError).ProcessState.ExitCode() == 30 {
return fmt.Errorf("pre-upgrade command failed : %w", err)
}
if err.(*exec.ExitError).ProcessState.ExitCode() == 31 {
Logger.Info().Msgf("pre-upgrade command failed. retrying.")
Logger.Info().Msg("pre-upgrade command failed. retrying.")
return doPreUpgrade(cfg)
}
}
Logger.Info().Msgf("pre-upgrade successful. continuing the upgrade.")
Logger.Info().Msg("pre-upgrade successful. continuing the upgrade.")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions cosmovisor/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func DoUpgrade(cfg *Config, info UpgradeInfo) error {
}

// If not there, then we try to download it... maybe
Logger.Info().Msgf("[cosmovisor] No upgrade binary found, beginning to download it")
Logger.Info().Msg("[cosmovisor] No upgrade binary found, beginning to download it")
if err := DownloadBinary(cfg, info); err != nil {
return fmt.Errorf("cannot download binary. %w", err)
}
Logger.Info().Msgf("[cosmovisor] Downloading binary complete")
Logger.Info().Msg("[cosmovisor] Downloading binary complete")

// and then set the binary again
if err := EnsureBinary(cfg.UpgradeBin(info.Name)); err != nil {
Expand Down