daemon

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package daemon holds the full sandboxd boot sequence as a single reusable entrypoint, Run. The open-source cmd/sandboxd calls Run with a no-op control plane (controlplane.Noop()); a managed build calls the same Run with a provider backed by the private fleet client. Keeping boot in one exported function is what lets the managed binary reuse the entire daemon without forking main().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, logger *slog.Logger, makeProvider ProviderFactory) error

Run loads configuration and executes the full daemon boot sequence, blocking until ctx is cancelled (SIGINT/SIGTERM in the standard wrapper), then performs graceful shutdown. Every fatal boot failure is returned as a wrapped error rather than calling os.Exit; the thin main() wrapper turns a non-nil return into the exit(1) the historical main() did, so observable behavior is unchanged (process dies on boot failure) while the boot-failure paths stay testable. Returning also lets the deferred cleanup (store/mount/otel shutdown) run on failure, which os.Exit skipped. The returned error covers every boot phase; it is nil at graceful shutdown.

makeProvider supplies the control-plane capabilities. nil (the open-source default) means controlplane.Noop(): every non-PAT token rejected, every usage report a no-op, every create admitted, no enforcement loop.

Types

type FleetConfig

type FleetConfig struct {
	Enabled         bool
	Endpoint        string
	Token           string
	ContractRefresh time.Duration
}

FleetConfig is the subset of daemon configuration a control-plane provider needs, projected out of the internal config so a managed build can construct its provider without importing internal/config (which Go forbids across modules). It mirrors the SB_FLEET_* settings.

type ProviderFactory

type ProviderFactory func(ctx context.Context, fc FleetConfig) (controlplane.Provider, error)

ProviderFactory builds the control-plane provider from the resolved fleet config. The managed build supplies one (wiring the private avmctl client); the open-source build passes nil, which yields controlplane.Noop(). It receives ctx so a provider can start background work (e.g. contract refresh) bound to the daemon lifecycle.

Jump to

Keyboard shortcuts

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