daemon

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package daemon implements the kukeond process: it owns a controller.Exec, exposes the kukeonv1 API over a unix socket using net/rpc + jsonrpc, and manages its own lifecycle (listener, PID file, graceful shutdown).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
}

func NewController

func NewController() *Controller

func (*Controller) Restart

func (c *Controller) Restart() error

func (*Controller) Start

func (c *Controller) Start() error

func (*Controller) Status

func (c *Controller) Status() (apidaemon.Status, error)

func (*Controller) Stop

func (c *Controller) Stop() error

type DaemonFake

type DaemonFake struct{}

func NewDaemonFake

func NewDaemonFake() *DaemonFake

type KukeonV1Service

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

KukeonV1Service implements the net/rpc server methods for the KukeonV1 service. Each method always returns nil to net/rpc and carries structured errors inside the Reply envelope so errdefs sentinels survive the wire.

func NewKukeonV1Service

func NewKukeonV1Service(
	ctx context.Context,
	logger *slog.Logger,
	core kukeonv1.Client,
) *KukeonV1Service

NewKukeonV1Service constructs a service bound to the given kukeon Client. The service borrows the client; the caller owns its lifecycle.

func (*KukeonV1Service) ApplyDocuments

func (*KukeonV1Service) AttachContainer added in v0.2.0

func (s *KukeonV1Service) AttachContainer(
	args *kukeonv1.AttachContainerArgs,
	reply *kukeonv1.AttachContainerReply,
) error

AttachContainer is the placeholder endpoint shipped in #57. It enforces the Attachable gate at the API boundary; the full client lands in #66.

func (*KukeonV1Service) CreateCell

CreateCell is the net/rpc method for KukeonV1.CreateCell. net/rpc requires exported pointer-to-struct args and reply plus a single error return.

Cells created with Spec.AutoDelete=true (`kuke run --rm`) are not followed by a per-cell watcher goroutine — the daemon's reconcile loop observes the root task exit on a subsequent tick and runs the kill+delete sequence. That makes AutoDelete cleanup restart-resilient: a cell whose Spec.AutoDelete=true survives a daemon restart still gets cleaned up after the daemon is back, without per-cell startup wiring.

func (*KukeonV1Service) CreateContainer

func (s *KukeonV1Service) CreateContainer(
	args *kukeonv1.CreateContainerArgs,
	reply *kukeonv1.CreateContainerReply,
) error

CreateContainer is the net/rpc method for KukeonV1.CreateContainer.

func (*KukeonV1Service) CreateRealm

CreateRealm is the net/rpc method for KukeonV1.CreateRealm.

func (*KukeonV1Service) CreateSpace

CreateSpace is the net/rpc method for KukeonV1.CreateSpace.

func (*KukeonV1Service) CreateStack

CreateStack is the net/rpc method for KukeonV1.CreateStack.

func (*KukeonV1Service) DeleteCell

func (*KukeonV1Service) DeleteContainer

func (s *KukeonV1Service) DeleteContainer(
	args *kukeonv1.DeleteContainerArgs,
	reply *kukeonv1.DeleteContainerReply,
) error

func (*KukeonV1Service) DeleteImage added in v0.3.0

func (*KukeonV1Service) DeleteRealm

func (*KukeonV1Service) DeleteSpace

func (*KukeonV1Service) DeleteStack

func (*KukeonV1Service) GetCell

func (s *KukeonV1Service) GetCell(args *kukeonv1.GetCellArgs, reply *kukeonv1.GetCellReply) error

func (*KukeonV1Service) GetContainer

func (*KukeonV1Service) GetImage added in v0.3.0

func (s *KukeonV1Service) GetImage(args *kukeonv1.GetImageArgs, reply *kukeonv1.GetImageReply) error

func (*KukeonV1Service) GetRealm

func (s *KukeonV1Service) GetRealm(args *kukeonv1.GetRealmArgs, reply *kukeonv1.GetRealmReply) error

func (*KukeonV1Service) GetSpace

func (s *KukeonV1Service) GetSpace(args *kukeonv1.GetSpaceArgs, reply *kukeonv1.GetSpaceReply) error

func (*KukeonV1Service) GetStack

func (s *KukeonV1Service) GetStack(args *kukeonv1.GetStackArgs, reply *kukeonv1.GetStackReply) error

func (*KukeonV1Service) KillCell

func (s *KukeonV1Service) KillCell(args *kukeonv1.KillCellArgs, reply *kukeonv1.KillCellReply) error

func (*KukeonV1Service) KillContainer

func (*KukeonV1Service) ListCells

func (s *KukeonV1Service) ListCells(args *kukeonv1.ListCellsArgs, reply *kukeonv1.ListCellsReply) error

func (*KukeonV1Service) ListContainers

func (*KukeonV1Service) ListImages added in v0.3.0

func (*KukeonV1Service) ListRealms

func (*KukeonV1Service) ListSpaces

func (*KukeonV1Service) ListStacks

func (*KukeonV1Service) LoadImage added in v0.3.0

func (s *KukeonV1Service) LoadImage(args *kukeonv1.LoadImageArgs, reply *kukeonv1.LoadImageReply) error

func (*KukeonV1Service) LogContainer added in v0.3.0

func (s *KukeonV1Service) LogContainer(
	args *kukeonv1.LogContainerArgs,
	reply *kukeonv1.LogContainerReply,
) error

LogContainer enforces the Attachable gate at the API boundary and returns the host path of the per-container sbsh capture file. Bytes never traverse this RPC — the client tails HostCapturePath directly.

func (*KukeonV1Service) Ping

Ping acks that the kukeonv1 RPC handler is serving and reports the daemon build version. Used by `kuke init` to wait until kukeond is ready.

func (*KukeonV1Service) PurgeCell

func (s *KukeonV1Service) PurgeCell(args *kukeonv1.PurgeCellArgs, reply *kukeonv1.PurgeCellReply) error

func (*KukeonV1Service) PurgeContainer

func (*KukeonV1Service) PurgeRealm

func (*KukeonV1Service) PurgeSpace

func (*KukeonV1Service) PurgeStack

func (*KukeonV1Service) RefreshAll

func (*KukeonV1Service) StartCell

func (s *KukeonV1Service) StartCell(args *kukeonv1.StartCellArgs, reply *kukeonv1.StartCellReply) error

func (*KukeonV1Service) StartContainer

func (*KukeonV1Service) StopCell

func (s *KukeonV1Service) StopCell(args *kukeonv1.StopCellArgs, reply *kukeonv1.StopCellReply) error

func (*KukeonV1Service) StopContainer

type Options

type Options struct {
	// SocketPath is the unix socket path the daemon listens on.
	SocketPath string
	// SocketMode is the file mode applied to the socket after creation.
	SocketMode os.FileMode
	// SocketGID, when non-zero, is the group the listener socket is chowned
	// to (uid stays root) so non-root members of that group can dial the
	// daemon. Set by `kuke init` to the kukeon GID. Each Serve re-applies
	// this so a daemon restart does not lose group access.
	SocketGID int
	// PIDFile, when non-empty, is written on Serve and removed on Stop.
	PIDFile string
	// ReconcileInterval is the period of the background cell-reconciliation
	// loop. Zero or negative disables the loop — useful for tests and for
	// operators who explicitly opt out via `--reconcile-interval 0`.
	ReconcileInterval time.Duration
	// Controller is forwarded to controller.NewControllerExec.
	Controller controller.Options
}

Options configures a Server.

type Server

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

Server hosts the kukeonv1 API over JSON-RPC on a unix socket.

func NewServer

func NewServer(ctx context.Context, logger *slog.Logger, opts Options) *Server

NewServer constructs a Server. It does not open the listener; call Serve.

func (*Server) Serve

func (s *Server) Serve() error

Serve opens the listener and accepts connections until Stop is called or the context is cancelled. Returns nil on graceful shutdown.

func (*Server) Stop

func (s *Server) Stop() error

Stop closes the listener, releases the controller, and removes the socket and PID file. Safe to call multiple times.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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