initsys

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 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 initsys is how osapi runs a program as a service under the service manager of a host: systemd on Linux and launchd on macOS. It makes the file of the service and the commands that load, start, stop and remove it. The caller writes the file and runs the commands with its own file system and runner: osapi agent service install as root, or the service behavior through its host, with sudo.

Index

Constants

View Source
const (
	SystemdDir = "/etc/systemd/system"
	LaunchdDir = "/Library/LaunchDaemons"
)

The directories of the service files.

Variables

This section is empty.

Functions

func LaunchdLoad

func LaunchdLoad(
	label string,
) [][]string

LaunchdLoad are the commands that load the plist of label into the system domain, which starts it.

func LaunchdPath

func LaunchdPath(
	label string,
) string

LaunchdPath is the plist of the label, such as /Library/LaunchDaemons/io.osapi.agent.plist.

func LaunchdPlist

func LaunchdPlist(
	s Service,
) []byte

LaunchdPlist is the plist of s, a daemon that launchd starts at boot and starts again when it stops.

func LaunchdUnload

func LaunchdUnload(
	label string,
) [][]string

LaunchdUnload are the commands that stop the daemon label and unload it. Remove its plist after them, to remove the service.

func SystemdAct

func SystemdAct(
	action string,
	name string,
) []string

SystemdAct is the command of action, such as start or restart, on the service name.

func SystemdDisable

func SystemdDisable(
	name string,
) [][]string

SystemdDisable are the commands that stop the service name and keep it from starting at boot, then forget its unit. Remove the unit file between the two, to remove the service.

func SystemdEnable

func SystemdEnable(
	name string,
) [][]string

SystemdEnable are the commands that load the unit of name and start it, now and at each boot.

func SystemdPath

func SystemdPath(
	name string,
) string

SystemdPath is the unit file of the service name, such as /etc/systemd/system/osapi-agent.service.

func SystemdReload

func SystemdReload() []string

SystemdReload is the command that makes systemd read the unit files again, after one of them changed.

func SystemdUnit

func SystemdUnit(
	s Service,
) []byte

SystemdUnit is the unit file of s: it starts after the network is up, and systemd starts it again 5 seconds after it stops.

Types

type Service

type Service struct {
	Name        string
	Label       string
	Description string
	Args        []string
	Log         string
	// Header is the comment at the top of the file, one line each, such as
	// who wrote it.
	Header []string
}

Service is a program that a service manager runs: its name, such as osapi-agent, its launchd label, such as io.osapi.agent, its description, the program and its arguments, and the log of launchd.

Jump to

Keyboard shortcuts

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