daemon

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package daemon program is installed as a system service to achieve process daemon

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameFieldRequired       = errors.New("config.name field is required")
	ErrNoServiceSystemDetected = errors.New("no service system detected")
	ErrNotAnRootUser           = errors.New("need to execute with sudo permission")
	ErrNotAnAdministrator      = errors.New("please operate with administrator rights")
)

Functions

func IsPermissionError

func IsPermissionError(err error) bool

func KillSignal added in v1.6.0

func KillSignal() bool

func ReSingleKillSignal added in v1.7.11

func ReSingleKillSignal()

func SignalChan added in v1.6.0

func SignalChan() (<-chan os.Signal, func())

func SingleKillSignal added in v1.6.0

func SingleKillSignal() <-chan bool

Types

type Config

type Config struct {
	Options     map[string]interface{}
	Name        string
	DisplayName string
	Description string
	UserName    string
	Executable  string
	WorkingDir  string
	RootDir     string
	Arguments   []string
	Context     context.Context
}

Config provides the setup for a ServiceIface. The Name field is required.

type Iface added in v1.3.0

type Iface interface {
	Start(s ServiceIface) error
	Stop(s ServiceIface) error
}

type ServiceIface added in v1.3.0

type ServiceIface interface {
	Run() error
	Start() error
	Stop() error
	Restart() error
	Install() error
	Uninstall() error
	Status() string
	String() string
}

ServiceIface represents a service that can be run or controlled

func New

func New(i Iface, c *Config) (ServiceIface, error)

New creates a new service based on a service interface and configuration

type SystemIface added in v1.3.0

type SystemIface interface {
	String() string
	Interactive() bool
	Detect() bool
	New(i Iface, c *Config) (ServiceIface, error)
}

Jump to

Keyboard shortcuts

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