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, rebootInfo *boot.RebootInfo)
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, rebootInfo *boot.RebootInfo) // 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 ¶
type RestartManager struct {
// contains filtered or unexported fields
}
RestartManager takes care of restart-related state.
func Manager ¶
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 ¶
func (m *RestartManager) Ensure() error
Ensure implements StateManager.Ensure. Required by StateEngine, we actually do nothing here.
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 )
func MockPending ¶
func MockPending(st *state.State, restarting RestartType) RestartType