systemd

package
v1.3.4-alpha11 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exports = map[string]interface{}{
	"Create": create,

	"unit_description":          WithUnitDescription,
	"unit_documentation":        WithUnitDocumentation,
	"unit_after":                WithUnitAfter,
	"unit_before":               WithUnitBefore,
	"unit_requires":             WithUnitRequires,
	"unit_binds_to":             WithUnitBindsTo,
	"unit_wants":                WithUnitWants,
	"unit_extra_line":           WithUnitExtraLine,
	"service_type":              WithServiceType,
	"service_user":              WithServiceUser,
	"service_group":             WithServiceGroup,
	"service_exec_start":        WithServiceExecStart,
	"service_exec_start_pre":    WithServiceExecStartPre,
	"service_exec_start_post":   WithServiceExecStartPost,
	"service_exec_stop":         WithServiceExecStop,
	"service_exec_stop_post":    WithServiceExecStopPost,
	"service_restart":           WithServiceRestart,
	"service_restart_sec":       WithServiceRestartSec,
	"service_timeout_start_sec": WithServiceTimeoutStartSec,
	"service_environment":       WithServiceEnvironment,
	"service_environment_file":  WithServiceEnvironmentFile,
	"service_umask":             WithServiceUmask,
	"service_raw":               WithServiceExtraLine,
	"service_stdin":             WithServiceStandardInput,
	"service_stdout":            WithServiceStandardOutput,
	"service_stderr":            WithServiceStandardError,
	"service_kill_signal":       WithServiceKillSignal,
	"service_kill9":             WithServiceKillSignal9,
	"install_wanted_by":         WithInstallWantedBy,
	"timer_calendar":            WithTimerOnCalendar,
	"timer_active_sec":          WithTimerOnActiveSec,
	"timer_unit":                WithTimerUnit,
	"timer_boot_sec":            WithTimerOnBootSec,
	"timer_startup_sec":         WithTimerOnStartupSec,
	"timer_unit_active_sec":     WithTimerOnUnitActiveSec,
	"timer_unit_inactive_sec":   WithTimerOnUnitInactiveSec,
	"timer_raw":                 WithTimerExtraLine,
	"extra_raw":                 WithRaw,
	"service_kill_mode":         WithServiceKillMode,
}

Functions

This section is empty.

Types

type ConfigOption

type ConfigOption func(*SystemdServiceConfig)

func WithInstallWantedBy

func WithInstallWantedBy(wantedBy string) ConfigOption

func WithRaw

func WithRaw(i string) ConfigOption

func WithServiceEnvironment

func WithServiceEnvironment(environment string) ConfigOption

func WithServiceEnvironmentFile

func WithServiceEnvironmentFile(environmentFile string) ConfigOption

func WithServiceExecStart

func WithServiceExecStart(execStart string) ConfigOption

func WithServiceExecStartPost

func WithServiceExecStartPost(execStartPost string) ConfigOption

func WithServiceExecStartPre

func WithServiceExecStartPre(execStartPre string) ConfigOption

func WithServiceExecStop

func WithServiceExecStop(execStop string) ConfigOption

func WithServiceExecStopPost

func WithServiceExecStopPost(execStopPost string) ConfigOption

func WithServiceExtraLine

func WithServiceExtraLine(extraLine string) ConfigOption

func WithServiceGroup

func WithServiceGroup(group string) ConfigOption

func WithServiceKillMode

func WithServiceKillMode(killMode string) ConfigOption

func WithServiceKillSignal

func WithServiceKillSignal(killSignal string) ConfigOption

func WithServiceKillSignal9

func WithServiceKillSignal9() ConfigOption

func WithServiceRestart

func WithServiceRestart(restart string) ConfigOption

func WithServiceRestartSec

func WithServiceRestartSec(restartSec float64) ConfigOption

func WithServiceStandardError

func WithServiceStandardError(standardError string) ConfigOption

func WithServiceStandardInput

func WithServiceStandardInput(standardInput string) ConfigOption

func WithServiceStandardOutput

func WithServiceStandardOutput(standardOutput string) ConfigOption

func WithServiceTimeoutStartSec

func WithServiceTimeoutStartSec(timeoutStartSec float64) ConfigOption

func WithServiceType

func WithServiceType(serviceType string) ConfigOption

func WithServiceUmask

func WithServiceUmask(umask string) ConfigOption

func WithServiceUser

func WithServiceUser(user string) ConfigOption

func WithTimerExtraLine

func WithTimerExtraLine(extraLine string) ConfigOption

func WithTimerOnActiveSec

func WithTimerOnActiveSec(onActiveSec int64) ConfigOption

func WithTimerOnBootSec

func WithTimerOnBootSec(onBootSec int64) ConfigOption

func WithTimerOnCalendar

func WithTimerOnCalendar(onCalendar string) ConfigOption

func WithTimerOnStartupSec

func WithTimerOnStartupSec(onStartupSec int64) ConfigOption

func WithTimerOnUnitActiveSec

func WithTimerOnUnitActiveSec(onUnitActiveSec int64) ConfigOption

func WithTimerOnUnitInactiveSec

func WithTimerOnUnitInactiveSec(s int64) ConfigOption

func WithTimerUnit

func WithTimerUnit(unit string) ConfigOption

func WithUnitAfter

func WithUnitAfter(after string) ConfigOption

func WithUnitBefore

func WithUnitBefore(before string) ConfigOption

func WithUnitBindsTo

func WithUnitBindsTo(bindsTo string) ConfigOption

func WithUnitDescription

func WithUnitDescription(description string) ConfigOption

func WithUnitDocumentation

func WithUnitDocumentation(documentation string) ConfigOption

func WithUnitExtraLine

func WithUnitExtraLine(extraLine string) ConfigOption

func WithUnitRequires

func WithUnitRequires(requires string) ConfigOption

func WithUnitWants

func WithUnitWants(wants string) ConfigOption

type SystemdServiceConfig

type SystemdServiceConfig struct {
	Name string

	Description   string
	Documentation string
	After         string // 在某个服务后启动
	Before        string // 在某个服务前启动
	Requires      string // 强依赖
	BindsTo       string // 绑定到某个服务,强依赖:绑定服务停止,这个服务也停止
	Wants         string // 弱依赖
	UnitExtraLine []string

	// 默认为 simple
	/*
		simple(默认):ExecStart 指定的命令将立即启动,并认为服务已启动。
		forking:ExecStart 指定的进程将自行分叉(fork),父进程退出后认为服务已启动。
		oneshot:ExecStart 指定的进程将运行并完成,然后服务进入非活动状态。
		dbus:服务启动后将等待 D-Bus 信号,确认服务已启动。
		notify:服务启动后将通过 sd_notify 发送通知,确认服务已启动。
		idle:类似于 simple,但仅在系统空闲时启动服务。
	*/
	ServicesType     string // simple, forking, oneshot, dbus, notify, idle
	User             string
	Group            string
	ExecStart        string
	ExecStartPre     string
	ExecStartPost    string
	ExecStop         string
	ExecStopPost     string
	Restart          string // no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, always
	RestartSec       float64
	TimeoutStartSec  float64
	Environment      string
	EnvironmentFile  string
	Umask            string
	StandardInput    string // null, tty, tty-force, tty-fail, socket, fd, fd-force, fd-fail, file, file-force, file-fail
	StandardOutput   string // inherit, null, tty, journal, syslog, kmsg, journal+console, syslog+console, kmsg+console, socket, fd, file
	StandardError    string // inherit, null, tty, journal, syslog, kmsg, journal+console, syslog+console, kmsg+console, socket, fd, file
	KillMode         string // control-group, process, mixed, none
	KillSignal       string // 默认应该是 -9
	ServiceExtraLine []string

	// Timer
	OnActiveSec       int64
	OnBootSec         int64
	OnStartupSec      int64
	OnUnitActiveSec   int64
	OnUnitInactiveSec int64
	OnCalendar        string
	TimerUnit         string
	TimerExtraLine    []string
	Persistent        string

	// Install
	InstallWantedBy string // 默认为 multi-user.target

	// Extra
	Raw string
}

func NewSystemServiceConfig

func NewSystemServiceConfig(name string, opt ...ConfigOption) *SystemdServiceConfig

func (*SystemdServiceConfig) ToServiceFile

func (c *SystemdServiceConfig) ToServiceFile() (string, string)

Jump to

Keyboard shortcuts

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