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

daemon

package
v0.1.2676 Latest Latest
Warning

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

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

Documentation

Overview

Package daemon runs `magpie serve` as a service of the user's own: a systemd user unit on Linux, a launch agent on the Mac. The system starts it at boot or login and starts it again when it stops, with no window and no desktop session, for a server or a machine reached over SSH. Whether it is installed and running is the system's own record, read each time, never a setting of magpie's.

Index

Constants

View Source
const Label = "com.yetone.magpie.serve"

Label is the launch agent's; the tray's at login is com.yetone.magpie.

View Source
const Name = "magpie"

Name is the service's name: magpie.service, com.yetone.magpie.serve.

Variables

View Source
var ErrNotInstalled = errors.New("the magpie service isn't installed: `magpie daemon install`")

ErrNotInstalled is Start, Stop or Restart before Install.

View Source
var ErrUnsupported = errors.New("unsupported")

ErrUnsupported is for a system with no service manager magpie writes for.

Functions

func Install

func Install(o Options) error

Install writes the service for this copy of magpie, with the environment it was installed from, and starts it; again, it writes the service anew (a moved magpie, a new PATH or proxy) and restarts it.

func Linger

func Linger() string

Linger is lingerAdvice, for after an install.

func Node

func Node() string

Node is the node the service finds on its PATH, "" for none: what the CLI warns of after an install.

func Removed added in v0.1.1483

func Removed() bool

Removed says the user removed the service, and hasn't installed it since.

func Restart

func Restart() error

Restart stops it and starts it again: a magpie updated in place serves as the new version.

func Start

func Start() error

Start starts the installed service.

func Stop

func Stop() error

Stop stops it, until the next boot or login, or Start.

func TLS added in v0.1.1232

func TLS() (cert, key string)

TLS is the certificate and key files the installed service serves HTTPS with (`magpie daemon install --tls-cert … --tls-key …`), "" when it has none or isn't installed.

func Uninstall

func Uninstall() error

Uninstall stops the service and removes it. One not installed is left as it is.

func Web added in v0.1.1231

func Web() (addr, key string)

Web is the page the installed service serves: its address and key, "" when it serves none or isn't installed. Read from the service's own file, which is the user's alone.

Types

type Options added in v0.1.1231

type Options struct {
	// Web is the address the app's page is served on (`magpie serve
	// --web=…`), "" for none.
	Web string
	// Key is the page's MAGPIE_WEB_KEY, written into the service so its
	// link stays the same across restarts; needed with Web.
	Key string
}

Options are what the service serves besides the gateway.

type Status

type Status struct {
	Installed bool   // the unit or launch agent is on disk
	Enabled   bool   // started at boot or login
	Running   bool   // its process is up
	PID       int    // that process, when the system says
	State     string // the system's own word for it: active, failed, running…
	LastExit  string // how its last run ended, when the system says
	File      string // the unit or launch agent's file
	Logs      string // how to read what it printed
	Advice    []string
}

Status is what the system says of the service.

func Get

func Get() (Status, error)

Get is what the system says of the service.

Jump to

Keyboard shortcuts

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