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(daemon): add Err() to retrieve the tomb death reason #453

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internals/cli/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ out:
break out
case <-d.Dying():
// something called Stop()
logger.Noticef("Server exiting!")
logger.Noticef("Server exiting! Reason: %v", d.Err())
break out
case <-checkTicker:
if err := sanityCheck(); err == nil {
Expand Down
6 changes: 6 additions & 0 deletions internals/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,12 @@ func (d *Daemon) Dying() <-chan struct{} {
return d.tomb.Dying()
}

// Err returns the death reason, or ErrStillAlive
// if the tomb is not in a dying or dead state.
Comment on lines +779 to +780
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment taken from d.tomb.Err()'s documentation.

func (d *Daemon) Err() error {
return d.tomb.Err()
}

func clearReboot(st *state.State) {
// FIXME See notes in the state package. This logic should be
// centralized in the overlord which is the orchestrator. Right
Expand Down
Loading