sysinit

package
v1.33.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package sysinit provides an abstraction over init systems like systemctl

Package sysinit provides an abstraction over init systems like systemctl

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// Name returns the name of the init manager
	Name() string

	// Active returns if a service is active
	Active(string) bool

	// Disable disables a service
	Disable(string) error

	// Disable disables a service and stops it right after.
	DisableNow(string) error

	// Mask prevents a service from being started
	Mask(string) error

	// Enable enables a service
	Enable(string) error

	// EnableNow enables a service and starts it right after.
	EnableNow(string) error

	// Unmask allows a service to be started
	Unmask(string) error

	// Start starts a service idempotently
	Start(string) error

	// Restart restarts a service
	Restart(string) error

	// Reload restarts a service
	Reload(string) error

	// Stop stops a service
	Stop(string) error

	// ForceStop stops a service with prejudice
	ForceStop(string) error

	// GenerateInitShim generates any additional init files required for this service
	GenerateInitShim(svc string, binary string, unit string) ([]assets.CopyableFile, error)
}

Manager is a common interface for init systems

func New

func New(r Runner) Manager

New returns an appropriately configured service manager

type OpenRC

type OpenRC struct {
	// contains filtered or unexported fields
}

OpenRC is a service manager for OpenRC-like init systems

func (*OpenRC) Active

func (s *OpenRC) Active(svc string) bool

Active checks if a service is running

func (*OpenRC) Disable

func (s *OpenRC) Disable(_ string) error

Disable does nothing

func (*OpenRC) DisableNow added in v1.18.0

func (s *OpenRC) DisableNow(svc string) error

DisableNow does Disable + Stop

func (*OpenRC) Enable

func (s *OpenRC) Enable(_ string) error

Enable does nothing

func (*OpenRC) EnableNow added in v1.18.0

func (s *OpenRC) EnableNow(svc string) error

EnableNow does Enable + Start

func (*OpenRC) ForceStop

func (s *OpenRC) ForceStop(svc string) error

ForceStop stops a service with prejuidice

func (*OpenRC) GenerateInitShim

func (s *OpenRC) GenerateInitShim(svc string, binary string, unit string) ([]assets.CopyableFile, error)

GenerateInitShim generates any additional init files required for this service

func (*OpenRC) Mask added in v1.20.0

func (s *OpenRC) Mask(_ string) error

Mask does nothing

func (*OpenRC) Name

func (s *OpenRC) Name() string

Name returns the name of the init system

func (*OpenRC) Reload added in v1.16.0

func (s *OpenRC) Reload(_ string) error

Reload reloads a service currently only used by our docker-env that doesn't need openrc implementation

func (*OpenRC) Restart

func (s *OpenRC) Restart(svc string) error

Restart restarts a service

func (*OpenRC) Start

func (s *OpenRC) Start(svc string) error

Start starts a service idempotently

func (*OpenRC) Stop

func (s *OpenRC) Stop(svc string) error

Stop stops a service

func (*OpenRC) Unmask added in v1.20.0

func (s *OpenRC) Unmask(_ string) error

Unmask does nothing

type Runner

type Runner interface {
	RunCmd(cmd *exec.Cmd) (*command.RunResult, error)
}

Runner is the subset of command.Runner this package consumes

type Systemd

type Systemd struct {
	// contains filtered or unexported fields
}

Systemd is a service manager for systemd distributions

func (*Systemd) Active

func (s *Systemd) Active(svc string) bool

Active checks if a service is running

func (*Systemd) Disable

func (s *Systemd) Disable(svc string) error

Disable disables a service

func (*Systemd) DisableNow added in v1.18.0

func (s *Systemd) DisableNow(svc string) error

DisableNow disables a service and stops it too (not waiting for next restart)

func (*Systemd) Enable

func (s *Systemd) Enable(svc string) error

Enable enables a service

func (*Systemd) EnableNow added in v1.18.0

func (s *Systemd) EnableNow(svc string) error

EnableNow enables a service and then activates it too (not waiting for next start)

func (*Systemd) ForceStop

func (s *Systemd) ForceStop(svc string) error

ForceStop terminates a service with prejudice

func (*Systemd) GenerateInitShim

func (s *Systemd) GenerateInitShim(_, _, _ string) ([]assets.CopyableFile, error)

GenerateInitShim does nothing for systemd

func (*Systemd) Mask added in v1.20.0

func (s *Systemd) Mask(svc string) error

Mask prevents a service from being started

func (*Systemd) Name

func (s *Systemd) Name() string

Name returns the name of the init system

func (*Systemd) Reload added in v1.16.0

func (s *Systemd) Reload(svc string) error

Reload reloads a service

func (*Systemd) Restart

func (s *Systemd) Restart(svc string) error

Restart restarts a service

func (*Systemd) Start

func (s *Systemd) Start(svc string) error

Start starts a service

func (*Systemd) Stop

func (s *Systemd) Stop(svc string) error

Stop stops a service

func (*Systemd) Unmask added in v1.20.0

func (s *Systemd) Unmask(svc string) error

Unmask allows a service to be started

Jump to

Keyboard shortcuts

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