restart

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

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

func ClearReboot(st *state.State)

ClearReboot clears state information about tracking requested reboots.

func ReplaceBootID

func ReplaceBootID(st *state.State, bootID string)

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

func Manager(st *state.State, curBootID string, h Handler) (*RestartManager, error)

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

func Pending

func Pending(st *state.State) (bool, RestartType)

Pending returns whether a restart was requested with Request and of which type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL