service

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package service handles host service installation: launchd on macOS, systemd user units on Linux. Used by `dejima service install/uninstall`.

Package service handles installing dejimad as a host service (launchd on macOS, systemd user units on Linux). The CLI's `dejima service install` command is a thin wrapper over this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SystemUnit added in v0.9.6

func SystemUnit() bool

SystemUnit reports whether the installed dejimad unit is a SYSTEM unit rather than a user unit — which is the WSL shape, since `dejima wsl setup` writes to /etc/systemd/system so the daemon starts with the distro's init as root.

Exported because a caller outside this package composes the restart advice an operator will copy and run, and advice naming the wrong scope fails with a message about a unit that "does not exist" while the unit sits on disk.

func UnitInstalled added in v0.9.4

func UnitInstalled() bool

UnitInstalled reports whether a dejimad unit exists on this host, in EITHER scope.

Distinct from "does this host run systemd", and the distinction is the whole point: a WSL distro can run systemd perfectly well and still have no dejimad unit, because the daemon there may be launched from the Windows side. An operator in exactly that state was told to run `sudo systemctl restart dejimad` after a self-update, and the restart the daemon had just attempted had already failed with "is the service installed?".

Types

type Action

type Action string

Action is install, uninstall, status, etc.

const (
	ActionInstall   Action = "install"
	ActionUninstall Action = "uninstall"
	ActionStatus    Action = "status"
)

type Manager

type Manager interface {
	// Install registers dejimad with the host service manager. args are the
	// extra command-line arguments baked into the service definition (e.g.
	// ["--tcp", ":7273"] to expose the Tailscale-pinned TCP listener).
	Install(binaryPath string, args []string) error
	Uninstall() error
	Status() (string, error)
	// Restart bounces the running daemon (e.g. after `make install` or a
	// release upgrade replaced the binary).
	Restart() error
}

Manager is the OS-specific service manager.

func New

func New(system bool) (Manager, error)

New returns a Manager appropriate for the current OS. With system=true on macOS it manages a system-wide LaunchDaemon instead of a per-user LaunchAgent — that's the reboot-durable option for headless Macs, where the gui launchd domain (which LaunchAgents need) never exists.

type Supervision

type Supervision struct {
	Managed       bool   // a service manager currently has dejimad loaded
	Mode          string // launchd-system | launchd-gui | launchd-user | systemd-user | none | unknown
	RebootDurable bool   // comes back after a reboot with no interactive login
	Summary       string // human one-liner for the report row
	Concern       string // non-empty → a reboot-survival caveat worth a WARN
}

Supervision describes how (and whether) dejimad is supervised by the host service manager, and whether that arrangement survives a reboot. It answers the question `dejima doctor` couldn't before: not just "is the daemon up?" but "will it come back on its own?".

func Detect

func Detect() Supervision

Detect inspects the host service manager for a dejimad supervision arrangement. Best-effort: never errors; returns Mode "none" when nothing is found and "unknown" on an unsupported OS.

Jump to

Keyboard shortcuts

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