Help us shape the future of Go! Take the 2026 Go Developer Survey

daemon

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package daemon serves sessionapi.API for one hive data directory on a unix socket, so every client on the machine shares one writer and one status tracker.

Index

Constants

View Source
const (
	LaunchdLabel    = "com.colonyops.hive.daemon"
	SystemdUnitName = "hive-daemon.service"
)

Variables

View Source
var ErrAlreadyRunning = errors.New("hive daemon already running")

Functions

func Run

func Run(ctx context.Context, opts Options) error

Run serves until ctx ends or a client calls Stop. It holds the instance lock for its whole life and removes the socket on the way out.

Types

type Options

type Options struct {
	Config *config.Config
	// Ports are the daemon's drivers. DB and Bus must be nil: Run opens them.
	// Stdout and Stderr should go to the log, since no terminal watches.
	Ports   hive.Ports
	Version string
	// WaitLock blocks until the running daemon exits instead of returning
	// ErrAlreadyRunning. The OS service units use it, so a unit restart
	// queues behind a daemon a client spawned.
	WaitLock bool
	// Reload loads the config a Reload RPC applies. nil rejects the RPC.
	Reload func(ctx context.Context) (*config.Config, error)
	// OnReady runs once the socket accepts connections.
	OnReady func(socketPath string)
	// OwnershipCheckInterval is how often the daemon checks it still owns its
	// data dir and socket. Zero means every 30s.
	OwnershipCheckInterval time.Duration
}

type Unit

type Unit struct {
	Path     string
	Contents string
}

Unit is an OS service definition for the daemon and the file it belongs in.

func LaunchdUnit

func LaunchdUnit(home, binary, dataDir, configPath string) Unit

LaunchdUnit is a launchd agent that keeps `<binary> daemon run --wait-lock` alive. --wait-lock queues it behind a daemon a client spawned, instead of exiting and being restarted in a loop. AbandonProcessGroup keeps launchd from killing a tmux server the daemon started when the daemon exits.

func SystemdUnit

func SystemdUnit(home, binary, dataDir, configPath string) Unit

SystemdUnit is a systemd user unit for `<binary> daemon run --wait-lock`. KillMode=process stops only the daemon on a restart, not a tmux server it started in its cgroup.

Directories

Path Synopsis
Package daemonpath names the files of the hive daemon for a data directory, so a client finds them without importing the daemon.
Package daemonpath names the files of the hive daemon for a data directory, so a client finds them without importing the daemon.
gen
Package wire converts between the hive.daemon.v1 messages and the Go types sessionapi.API speaks, for both the daemon and its client.
Package wire converts between the hive.daemon.v1 messages and the Go types sessionapi.API speaks, for both the daemon and its client.

Jump to

Keyboard shortcuts

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