-
Notifications
You must be signed in to change notification settings - Fork 57
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 ExternalMode
reboot
#529
Conversation
c8600fe
to
2fd9aea
Compare
ExternalMode
reboot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me, thanks. (Though I had one clarifying question.)
The only other thing I'd suggest is to use errors.Is
instead of err == daemon.ErrRestartExternal
in your PR description (though I see you've used it in the test code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for me now, thanks @anpep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This patch adds a new
daemon.ExternalMode
reboot mode that does nothing, so that code in charge of starting and stopping the Pebble daemon can run custom logic after the daemon has stopped.When
ExternalMode
is set and the Pebble daemon stops after a system restart has been requested,daemon.Stop()
returns the specialdaemon.ErrRestartExternal
error that can be detected by the caller in order to execute custom reboot logic.Furthermore, the fallback reboot handler is set to
syscallModeReboot()
, so that a system reboot is forced afterrebootWaitTimeout
is reached. In other words, the code responsible for handling the reboot with custom logic has a time span given byrebootWaitTimeout
to perform a system reboot, or it will be forced.