service

package
v1.43.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const RunModeEnv = "SERVICE_RUN_MODE"

Variables

View Source
var (
	ErrNotSupported     = errors.New("system not supported")
	ErrAlreadyInstalled = errors.New("already installed")
	ErrNoInstalled      = errors.New("not installed")
)

Functions

func Name added in v1.4.5

func Name(s Service) string

Name returns the name of s.

func Run

func Run(name string, r Runner) error

Types

type Config

type Config struct {
	Name        string
	DisplayName string
	Description string
	Arguments   []string
	Flags       []string
}

func (Config) HasFlag added in v1.37.0

func (c Config) HasFlag(flag string) bool

type ConfigDefaultTester added in v1.8.6

type ConfigDefaultTester interface {
	IsDefault() bool
}

type ConfigDuration

type ConfigDuration struct {
	Value   *time.Duration
	Default time.Duration
}

func (ConfigDuration) IsDefault added in v1.8.6

func (e ConfigDuration) IsDefault() bool

func (ConfigDuration) Set

func (e ConfigDuration) Set(v string) error

func (ConfigDuration) String

func (e ConfigDuration) String() string

type ConfigEntry

type ConfigEntry interface {
	Set(string) error
	String() string
}

type ConfigFileStorer

type ConfigFileStorer struct {
	File string
}

func (ConfigFileStorer) LoadConfig

func (s ConfigFileStorer) LoadConfig(c map[string]ConfigEntry) error

func (ConfigFileStorer) SaveConfig

func (s ConfigFileStorer) SaveConfig(c map[string]ConfigEntry) error

type ConfigFlag

type ConfigFlag struct {
	Value   *bool
	Default bool
}

func (ConfigFlag) IsDefault added in v1.8.6

func (e ConfigFlag) IsDefault() bool

func (ConfigFlag) Set

func (e ConfigFlag) Set(v string) error

func (ConfigFlag) String

func (e ConfigFlag) String() string

type ConfigListEntry

type ConfigListEntry interface {
	ConfigEntry
	Strings() []string
}

type ConfigStorer

type ConfigStorer interface {
	SaveConfig(map[string]ConfigEntry) error
	LoadConfig(map[string]ConfigEntry) error
}

type ConfigUint added in v1.33.0

type ConfigUint struct {
	Value   *uint
	Default uint
}

func (ConfigUint) IsDefault added in v1.33.0

func (e ConfigUint) IsDefault() bool

func (ConfigUint) Set added in v1.33.0

func (e ConfigUint) Set(v string) error

func (ConfigUint) String added in v1.33.0

func (e ConfigUint) String() string

type ConfigValue

type ConfigValue struct {
	Value   *string
	Default string
}

func (ConfigValue) IsDefault added in v1.8.6

func (e ConfigValue) IsDefault() bool

func (ConfigValue) Set

func (e ConfigValue) Set(v string) error

func (ConfigValue) String

func (e ConfigValue) String() string

type RunMode

type RunMode int
const (
	// RunModeNone means the current process is not run as a service.
	RunModeNone RunMode = iota

	// RunModeService specifies that the process is running as a service.
	RunModeService
)

func CurrentRunMode

func CurrentRunMode() RunMode

type Runner

type Runner interface {
	Start() error
	Stop() error
	Log(msg string)
}

type Service

type Service interface {
	Install() error
	Uninstall() error

	Status() (Status, error)
	Start() error
	Stop() error
	Restart() error

	ConfigStorer
}

type Status

type Status int
const (
	StatusUnknown Status = iota
	StatusNotInstalled
	StatusRunning
	StatusStopped
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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