service

package
v0.54.2 Latest Latest
Warning

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

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

Documentation

Overview

Package service installs the agent as a background service, on whichever init system the host actually has.

The agent has to keep running rather than fire once, because Solve needs it to be there when a fix is approved — a daily timer cannot answer a click. And it has to work on hosts older than systemd, because the neglected servers our users inherited are exactly those hosts.

Nothing outside this package knows which init system is in use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind is the init system this host uses.

const (
	Unsupported Kind = iota
	Systemd
	Upstart
)

func Detect

func Detect() Kind

Detect reports which init system is running here.

It reads /proc/1/comm rather than testing for /run/systemd/system, matching the detection already used by the services collector. That check is the honest one: /run/systemd/system exists in places systemd is not actually running pid 1, and two detectors that disagree is a bug waiting for a customer to find.

func (Kind) String

func (k Kind) String() string

type Manager

type Manager interface {
	Install(Spec) error
	Remove() error
}

Manager installs and removes the agent's service on one init system.

func For

func For(kind Kind) (Manager, error)

For returns the manager for this host, or an error naming what is missing. A host with no recognised init system is told plainly rather than given a service definition it will never read.

type Spec

type Spec struct {
	ExecStart string
	User      string
	Env       []string
}

Spec is what any init system needs to be told about the agent.

Env carries KEY=value settings the running service needs. It exists because the agent registers against one address and would otherwise report to another: the address is known at install time and forgotten by the time the service starts, unless the init system is told to pass it on.

Jump to

Keyboard shortcuts

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