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
- func LaunchdLoad(label string) [][]string
- func LaunchdPath(label string) string
- func LaunchdPlist(s Service) []byte
- func LaunchdUnload(label string) [][]string
- func SystemdAct(action string, name string) []string
- func SystemdDisable(name string) [][]string
- func SystemdEnable(name string) [][]string
- func SystemdPath(name string) string
- func SystemdReload() []string
- func SystemdUnit(s Service) []byte
- type Service
Constants ¶
const ( SystemdDir = "/etc/systemd/system" LaunchdDir = "/Library/LaunchDaemons" )
The directories of the service files.
Variables ¶
This section is empty.
Functions ¶
func LaunchdLoad ¶
LaunchdLoad are the commands that load the plist of label into the system domain, which starts it.
func LaunchdPath ¶
LaunchdPath is the plist of the label, such as /Library/LaunchDaemons/io.osapi.agent.plist.
func LaunchdPlist ¶
LaunchdPlist is the plist of s, a daemon that launchd starts at boot and starts again when it stops.
func LaunchdUnload ¶
LaunchdUnload are the commands that stop the daemon label and unload it. Remove its plist after them, to remove the service.
func SystemdAct ¶
SystemdAct is the command of action, such as start or restart, on the service name.
func SystemdDisable ¶
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 ¶
SystemdEnable are the commands that load the unit of name and start it, now and at each boot.
func SystemdPath ¶
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 ¶
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.