restart

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package restart implements requesting restarts from any part of the code that has access to state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootID

func BootID(st *state.State) string

func ClearReboot

func ClearReboot(st *state.State)

ClearReboot clears state information about tracking requested reboots.

func Init

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

Init 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 ReplaceBootID

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

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)
	// RebootIsFine is called early when either a reboot was
	// requested by snapd and happened or no reboot was expected at all.
	RebootIsFine(st *state.State) error
	// RebootIsMissing is called early instead when a reboot was
	// requested by snapd but did not happen.
	RebootIsMissing(st *state.State) error
}

Handler can handle restart requests and whether expected reboots happen.

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
)

func FakePending

func FakePending(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