sysd

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sysd generates systemd config files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConditionExists

type ConditionExists string

ConditionExists specifies a file must exist at the path.

func (ConditionExists) String

func (c ConditionExists) String() string

type ConditionFirstBoot added in v0.1.4

type ConditionFirstBoot string

ConditionFirstBoot specifies the current boot must be the first.

func (ConditionFirstBoot) String added in v0.1.4

func (c ConditionFirstBoot) String() string

type ConditionHost

type ConditionHost string

ConditionHost specifies the machine must be a given hostname or machine ID.

func (ConditionHost) String

func (c ConditionHost) String() string

type ConditionNotExists

type ConditionNotExists string

ConditionNotExists specifies a file must be missing at the path.

func (ConditionNotExists) String

func (c ConditionNotExists) String() string

type Conditions

type Conditions []conditional

Conditions describes a set of checks which must pass for the unit to run.

func (*Conditions) String

func (c *Conditions) String() string

String returns the conditions serialized into config lines.

type KillMode

type KillMode string

KillMode describes kill modes of a systemd service.

const (
	KMControlGroup KillMode = "control-group"
)

Valid kill modes.

type Mount

type Mount struct {
	WhatPath     string   // Absolute path to device to mount.
	WherePath    string   // Absolute path to mount point.
	FSType       string   // Optional file-system path.
	MountOptions []string // Options to use when mounting.
}

Mount describes a mount unit.

func (*Mount) String

func (s *Mount) String() string

String returns the configuration as a valid mount stanza.

type NotifySockMode

type NotifySockMode string

NotifySockMode describes access to the service status notification socket.

const (
	NoNotify        NotifySockMode = "none"
	NotifyMainProc  NotifySockMode = "main"
	NotifyExecProcs NotifySockMode = "exec"
	NotifyAllProcs  NotifySockMode = "all"
)

Valid NotifySockMode values.

type OutputSinks

type OutputSinks uint8

OutputSinks describes where standard output should be written.

const (
	OutputConsole OutputSinks = 1 << iota
	OutputJournal
	OutputInherit
	OutputSyslog
	OutputKmsg
)

Output sink flags.

func (OutputSinks) String

func (o OutputSinks) String() string

type RestartMode

type RestartMode string

RestartMode describes how/if a systemd service should be restarted.

const (
	RestartAlways     RestartMode = "always"
	RestartNever      RestartMode = "no"
	RestartOnSuccess  RestartMode = "on-success"
	RestartOnFailure  RestartMode = "on-failure"
	RestartOnAbnormal RestartMode = "on-abnormal"
	RestartOnWatchdog RestartMode = "on-watchdog"
	RestartOnAbort    RestartMode = "on-abort"
)

Valid restart modes.

type Service

type Service struct {
	Type        ServiceType
	ExecStart   string
	RootDir     string
	WorkingDir  string
	KillMode    KillMode
	User, Group string

	ExecReload   string
	ExecStop     string
	ExecStartPre string
	ExecStopPost string

	TimeoutStopSec time.Duration
	Restart        RestartMode
	RestartSec     time.Duration
	WatchdogSec    time.Duration

	NotifyAccess NotifySockMode

	IgnoreSigpipe bool
	Stdout        OutputSinks
	Stderr        OutputSinks

	Conditions Conditions
}

Service represents the configuration of a systemd service.

func (*Service) String

func (s *Service) String() string

String returns the configuration as a valid service stanza.

type ServiceType

type ServiceType string

ServiceType describes the type of systemd service.

const (
	// SimpleService is a service that launches a process. The service is
	// considered started once the unit initalizes, regardless of if the process
	// started successfully or not.
	SimpleService ServiceType = "simple"
	// ExecService is a service that launches a process, but blocks till the
	// fork and exec have happened successfully. The unit fails if either of
	// those system calls failed.
	ExecService ServiceType = "exec"
	// ForkingService is expected to fork itself then exit. Systemd will consider
	// the service started when the process the unit started exits.
	ForkingService ServiceType = "forking"
	// OneshotService represents a service which is considered started once the
	// main process exits.
	OneshotService ServiceType = "oneshot"
	// NotifyService is a service that launches a process. The process must notify
	// systemd when it has initialized.
	NotifyService ServiceType = "notify"
	// IdleService is a service that launches a process, but the launch is delayed
	// until active jobs are dispatched or 5s has elapsed.
	IdleService ServiceType = "idle"
)

type Unit

type Unit struct {
	Description string
	After       []string

	Service *Service
	Mount   *Mount

	WantedBy   []string
	RequiredBy []string
}

Unit represents the configuration of a systemd unit.

func (*Unit) String

func (u *Unit) String() string

String returns the structure represent in the correct file format.

Jump to

Keyboard shortcuts

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