boot

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package boot provides console log parsing and boot diagnostics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchEvents added in v0.2.0

func WatchEvents(ctx context.Context, path string, opts WatchOptions) <-chan Event

WatchEvents tails the file at path and emits one Event per new line. The returned channel is closed when ctx is canceled. It blocks while waiting for the file to appear and recovers from truncation/rotation by reopening when the file shrinks.

Unlike WatchFile, this function does not stop on its own — callers control the lifetime via ctx so they can keep streaming console output even after boot is "healthy" (the tail is still useful for diagnosing later failures).

func WatchFile

func WatchFile(path string, pollInterval time.Duration) <-chan *Status

WatchFile watches a console log file and returns status updates. Stops when status.Healthy() returns true or a fatal error is detected.

Types

type Event added in v0.2.0

type Event struct {
	Line   string
	Status Status
}

Event is a single observation made while tailing a console log. Line is the raw text (no trailing newline). Status is the accumulated boot status as of this line — a stable snapshot the caller may keep references to.

type Status

type Status struct {
	KernelBooted    bool
	SystemdReached  bool
	CloudInitDone   bool
	CloudInitFailed bool
	SSHReady        bool
	IncusReady      bool
	LoginPrompt     bool
	KernelPanic     bool
	EmergencyMode   bool

	// Errors detected during boot
	Errors []string

	// LastActivity timestamp detected
	LastActivity time.Time
}

Status represents the detected boot state from console output.

func ParseFile

func ParseFile(path string) (*Status, error)

ParseFile parses boot status from a console log file.

func ParseReader

func ParseReader(r io.Reader) *Status

ParseReader parses boot status from a reader (console log).

func (*Status) Healthy

func (s *Status) Healthy() bool

Healthy returns true if boot completed without critical failures.

func (*Status) Summary

func (s *Status) Summary() string

Summary returns a human-readable summary of boot status.

type WatchOptions added in v0.2.0

type WatchOptions struct {
	// PollInterval is how often to re-stat the file. Required.
	PollInterval time.Duration
	// FromEnd seeks to the end of the file on initial open so only content
	// appended after WatchEvents starts is emitted. Useful when the log may
	// already contain stale content from a previous run.
	FromEnd bool
}

WatchOptions configures WatchEvents.

Jump to

Keyboard shortcuts

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