Documentation ¶
Overview ¶
Package restart implements requesting restarts from any part of the code that has access to state. It also implements a mimimal manager to take care of restart state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearReboot ¶
ClearReboot clears state information about tracking requested reboots.
func ReplaceBootID ¶
func Request ¶
func Request(st *state.State, t RestartType)
Request asks for a restart of the managing process. The state needs to be locked to request a restart.
Types ¶
type Handler ¶
type Handler interface { HandleRestart(t RestartType) // RebootAsExpected is called early when either a reboot was // requested by snapd and happened or no reboot was expected at all. RebootAsExpected(st *state.State) error // RebootDidNotHappen is called early instead when a reboot was // requested by snapd but did not happen. RebootDidNotHappen(st *state.State) error }
Handler can handle restart requests and whether expected reboots happen.
type RestartManager ¶ added in v1.16.0
type RestartManager struct {
// contains filtered or unexported fields
}
RestartManager takes care of restart-related state.
func Manager ¶ added in v1.16.0
Manager returns a new restart manager and initializes the support for restarts requests. It takes the current boot id to track and verify reboots and a Handler that handles the actual requests and reacts to reboot happening. It must be called with the state lock held.
func (*RestartManager) Ensure ¶ added in v1.16.0
func (rm *RestartManager) Ensure() error
Ensure implements StateManager.Ensure. Required by StateEngine, we actually do nothing here.
func (*RestartManager) FakePending ¶ added in v1.16.0
func (rm *RestartManager) FakePending(restarting RestartType) RestartType
func (*RestartManager) Pending ¶ added in v1.16.0
func (rm *RestartManager) Pending() (bool, RestartType)
Pending returns whether a restart was requested with Request and of which type. NOTE: the state does not need to be locked to fetch this information.
type RestartType ¶
type RestartType int
const ( RestartUnset RestartType = iota RestartDaemon RestartSystem // RestartSystemNow is like RestartSystem but action is immediate RestartSystemNow // RestartSocket will restart the daemon so that it goes into // socket activation mode. RestartSocket // Stop just stops the daemon (used with image pre-seeding) StopDaemon // RestartSystemHaltNow will shutdown --halt the system asap RestartSystemHaltNow // RestartSystemPoweroffNow will shutdown --poweroff the system asap RestartSystemPoweroffNow RestartServiceFailure RestartCheckFailure )