Documentation
¶
Index ¶
- func RunPhase0(ctx context.Context, d Phase0Deps) error
- type Phase0Deps
- type Supervisor
- func (s *Supervisor) Bus() *eventbus.EventBus[*anypb.Any]
- func (s *Supervisor) EnablePid1(ctx context.Context) (func(action shutdown.Action), error)
- func (s *Supervisor) RequestShutdown(action shutdownpkg.Action)
- func (s *Supervisor) Run(ctx context.Context) error
- func (s *Supervisor) ShutdownRequests() <-chan shutdownpkg.Action
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunPhase0 ¶
func RunPhase0(ctx context.Context, d Phase0Deps) error
RunPhase0 executes the pre-userspace boot obligations in the order the kernel requires: subreaper first (a SIGCHLD needs a reaper), signal handlers next (PID 1 has no implicit defaults), the reap loop started, then early mounts before any subsystem assumes them. Mounts fail closed - a broken /proc corrupts everything after it - while the rest are best-effort with the caller logging.
Types ¶
type Phase0Deps ¶
type Phase0Deps struct {
// Subreaper marks this process as a child subreaper (prctl).
Subreaper func() error
// InstallSignal registers the explicit PID-1 signal handlers.
InstallSignal func()
// Mount runs the early filesystem mounts.
Mount func([]mounts.MountSpec) error
// StartReap launches the orphan reap loop for the process lifetime.
StartReap func(context.Context)
// SkipMounts honors --no-early-mounts (container environments).
SkipMounts bool
}
Phase0Deps are the pre-userspace obligations, injected so the boot ordering is unit-testable without touching real syscalls; the wiring to the concrete kernel packages lives in the daemon entrypoint, and the real integration is proven by the PID-1 container e2e.
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor manages the GAPI runtime lifecycle.
func (*Supervisor) Bus ¶
func (s *Supervisor) Bus() *eventbus.EventBus[*anypb.Any]
Bus returns the internal event bus.
func (*Supervisor) EnablePid1 ¶
EnablePid1 runs Phase 0 (pre-userspace) with the real kernel packages and installs the PID-1 signal semantics. Shutdown requests (signals here, the system.shutdown topic elsewhere) surface on ShutdownRequests(); the returned completion function runs after the runtime has stopped: sync, reverse umount, then reboot(2). Where reboot is not permitted (containers), the completion returns and the caller exits; for a container init, exiting IS poweroff.
func (*Supervisor) RequestShutdown ¶
func (s *Supervisor) RequestShutdown(action shutdownpkg.Action)
RequestShutdown records a system shutdown request; the first request wins and repeats are absorbed (the machine only goes down once).
func (*Supervisor) Run ¶
func (s *Supervisor) Run(ctx context.Context) error
Note: In a real library, Start might be non-blocking or accept a context. For now, we mirror the existing blocking behavior but allow external control via context cancellation if needed? The original used `runSupervisor()` which blocked on signal. We'll expose `Run()` which sets up handlers and blocks.
func (*Supervisor) ShutdownRequests ¶
func (s *Supervisor) ShutdownRequests() <-chan shutdownpkg.Action
ShutdownRequests exposes the request channel; the daemon entrypoint selects on it to cancel the run context and complete the teardown.