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

service

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package service installs the visor as a user service and dials it. The visor has its own service, separate from the product service, because launchd stops the whole process group of a job.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedOS = errors.New("service: this OS is not supported")

ErrUnsupportedOS means that the OS has no service manager that the package knows.

Functions

func Ensure

func Ensure(ctx context.Context, s Service) (*agentvisor.Client, error)

Ensure dials the visor. When no visor listens, it installs and starts the service, then waits for the socket.

func UserUnitDir

func UserUnitDir(goos string) (string, error)

UserUnitDir gives the folder of the user services for goos.

Types

type Service

type Service struct {
	// Label names the service, for example com.example.visor.
	Label string
	// Command starts the visor in the foreground, for example
	// [binary, "visor", "serve"].
	Command []string
	// Socket is the socket that the visor listens on.
	Socket string
	// UnitDir holds the unit file. See UserUnitDir.
	UnitDir string
	// LogPath gets the output of the visor process. Empty discards it.
	LogPath string
	// Env is the env of the visor process. The unit file has mode 0600.
	Env map[string]string
	// GOOS selects launchd (darwin) or systemd (linux). Empty is the OS of
	// this process.
	GOOS string
	// Wait is how long Ensure waits for the socket. Zero is 15 s.
	Wait time.Duration
	// Run runs a service manager command. Nil runs the program.
	Run func(ctx context.Context, name string, args ...string) error
}

Service describes the visor service of one product.

func (Service) Install

func (s Service) Install(ctx context.Context) error

Install writes the unit file, and starts or restarts the service.

func (Service) Remove

func (s Service) Remove(ctx context.Context) error

Remove stops the service and deletes the unit file.

func (Service) UnitPath

func (s Service) UnitPath() string

UnitPath gives the path of the unit file.

Jump to

Keyboard shortcuts

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