daemon

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package daemon implements the long-lived Masterblaster daemon service. The daemon manages VM sandbox lifecycles via a Backend, exposes a JSON-RPC API over a unix domain socket (~/.mb/mb.sock), and handles PID file management and liveness probes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRunning

func IsRunning(baseDir string) bool

IsRunning checks if the daemon is running by attempting to connect to the socket and sending a ping.

func PIDFilePath

func PIDFilePath(baseDir string) string

PIDFilePath returns the path to the daemon's PID file.

func SocketPath

func SocketPath(baseDir string) string

SocketPath returns the path to the daemon's unix socket.

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is the long-lived Masterblaster service that manages sandbox VMs. It acts as a multiplexer: each VM gets its own vmhost child process that holds the hypervisor handle and control socket. The daemon spawns vmhost processes, monitors their health, and routes CLI requests to them.

func New

func New(baseDir string) *Daemon

New creates a new Daemon with the given base directory. The daemon no longer takes a Backend parameter; instead, it spawns vmhost child processes that use the appropriate backend internally.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

Run starts the daemon, listens for CLI requests, and blocks until interrupted or the context is cancelled.

type RPCMethod

type RPCMethod string

RPCMethod identifies an RPC call from the CLI to the daemon.

const (
	MethodUp      RPCMethod = "up"
	MethodDown    RPCMethod = "down"
	MethodStatus  RPCMethod = "status"
	MethodDestroy RPCMethod = "destroy"
	MethodList    RPCMethod = "list"
	MethodPing    RPCMethod = "ping"
)

type Request

type Request struct {
	Method RPCMethod `json:"method"`

	// Up parameters
	Name       string `json:"name,omitempty"`
	ConfigPath string `json:"config_path,omitempty"`

	// Down/Destroy parameters
	Force bool `json:"force,omitempty"`

	// Status parameters
	All bool `json:"all,omitempty"`
}

Request is the wire format for CLI -> daemon RPC calls.

type Response

type Response struct {
	OK    bool   `json:"ok"`
	Error string `json:"error,omitempty"`

	// For status/list responses
	Sandboxes []SandboxInfo `json:"sandboxes,omitempty"`
}

Response is the wire format for daemon -> CLI responses.

type SandboxInfo

type SandboxInfo struct {
	Name        string `json:"name"`
	State       string `json:"state"`
	Mixtape     string `json:"mixtape"`
	CPUs        int    `json:"cpus"`
	Memory      string `json:"memory"`
	SSHPort     int    `json:"ssh_port"`
	SSHAddress  string `json:"ssh_address"`
	SSHKeyPath  string `json:"ssh_key_path,omitempty"`
	VsockPort   int    `json:"vsock_port"`
	NetworkMode string `json:"network_mode"`
}

SandboxInfo is the public representation of a sandbox for CLI display.

Directories

Path Synopsis
Package client provides a thin wrapper for CLI commands to communicate with the Masterblaster daemon over the unix domain socket.
Package client provides a thin wrapper for CLI commands to communicate with the Masterblaster daemon over the unix domain socket.

Jump to

Keyboard shortcuts

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