reboot

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reboot provides system reboot detection and scheduling through an injected exec.Runner.

Build a Manager with a Runner and call its methods. Scheduling escalates through the Runner; the reboot-required probe runs unprivileged.

r, _ := exec.NewRunner(exec.Sudo)
rb, _ := reboot.New(r)
if need, _ := rb.IsRequired(ctx); need {
	_ = rb.Schedule(ctx, reboot.ScheduleOptions{Delay: "+5", Message: "patching"})
}

Status: SDK-resident, single-consumer today (the agent's reboot-required + scheduled-reboot pipeline). Sits in the SDK because the planned server-side maintenance-window simulator needs the same "next reboot window" math. F027 in TECH_DEBT_AUDIT.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// IsRequired reports whether the system needs a reboot after updates. An
	// unsupported host (no marker file and no needs-restarting binary) yields
	// (false, nil) — absence of detection is not a failure. A genuinely
	// unexpected condition IS surfaced as an error: a non-ENOENT stat error on
	// the marker, or a needs-restarting run failure that isn't "tool absent"
	// (e.g. a cancelled/timed-out context).
	IsRequired(ctx context.Context) (bool, error)
	// Schedule schedules a reboot via shutdown -r using opts. An empty
	// opts.Delay defaults to "+1"; a non-empty opts.Message is broadcast to
	// logged-in users.
	Schedule(ctx context.Context, opts ScheduleOptions) error
	// Cancel cancels a pending scheduled reboot (shutdown -c).
	Cancel(ctx context.Context) error
}

Manager detects and schedules system reboots.

func New

func New(runner exec.Runner) (Manager, error)

New returns a Manager driven by runner. A nil runner is rejected.

type ScheduleOptions

type ScheduleOptions struct {
	// Delay is the reboot grace time, constrained to a positive relative minute
	// offset "+N" (N >= minRebootGraceMinutes). This is deliberately narrower
	// than shutdown(8)'s full TIME grammar: "now", "+0", a negative offset, and
	// absolute clock times (e.g. "23:00") are rejected so a reboot always leaves
	// a grace window for logged-in users. Empty defaults to "+1" (one minute).
	Delay string
	// Message, when non-empty, is the wall message broadcast to logged-in
	// users by shutdown.
	Message string
}

ScheduleOptions configures a scheduled reboot. Fields are named so callers can't transpose the (delay, message) pair, and so future knobs (e.g. a kexec fast-reboot) can be added without breaking the signature.

Jump to

Keyboard shortcuts

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