service

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service registers the daemon with the OS so it starts at login: a launchd agent on macOS, a systemd user unit on Linux.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSystemd = errors.New("this system does not run systemd")

ErrNoSystemd means this Linux system does not run systemd, so there is no user service manager to register the daemon with.

Functions

func File

func File() string

File returns the path of the service definition.

func Install

func Install(configPath string) error

Install writes the service definition and starts it. On Linux without systemd it returns ErrNoSystemd.

func LingerOff

func LingerOff() bool

LingerOff reports whether systemd ends the account's user services at logout (Linux only), so the daemon neither outlives a session nor starts at boot. It is false when this cannot be determined.

func MenuBarAppStartsDaemon() bool

MenuBarAppStartsDaemon reports whether the macOS menu bar app opens at login, which starts the daemon too. The app records that setting in its preferences.

func MissingDisplay

func MissingDisplay() bool

MissingDisplay reports, on Linux, whether this process runs in a desktop session (a local DISPLAY or a WAYLAND_DISPLAY) while the running service's daemon has neither, so it cannot show notifications or open windows.

func NoSystemdHint

func NoSystemdHint() string

NoSystemdHint explains how to start the daemon at login without systemd.

func Owns

func Owns(configPath string) bool

Owns reports whether the installed service runs the daemon for configPath with this process's state directory and the configured port, so starting the service starts the daemon that a client with these settings talks to. A service installed before it pinned the state directory runs with the default one.

func Restart

func Restart() error

Restart stops the service's daemon, if it runs, and starts it again.

func Start

func Start() error

Start starts the installed service's daemon if it is not running.

func Supported

func Supported() bool

Supported reports whether this system has a service manager that Install can use: launchd on macOS, a running systemd on Linux.

func Uninstall

func Uninstall() error

Uninstall stops the service and removes its definition.

Types

type Status

type Status struct {
	Installed bool
	Running   bool
	File      string
	Detail    string
}

Status describes the installed service.

func Query

func Query() Status

Query reports whether the service is installed and running.

Jump to

Keyboard shortcuts

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