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.
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.