daemon

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: MIT Imports: 11 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

Types

type Config

type Config struct {
	Name        string
	DisplayName string
	Description string
	UserName    string
	Arguments   []string
	Executable  string
	WorkingDir  string
	RootDir     string
	// System specific options
	//  * OS X
	//    - KeepAlive     bool (true)
	//    - RunAtLoad     bool (true)
	//    - UserService   bool (false) - Install as a current user service.
	//    - SessionCreate bool (false) - Create a full user session.
	//  * POSIX
	//    - RunWait      func() (wait for SIGNAL) - Do not install signal but wait for this function to return.
	//    - ReloadSignal string () [USR1, ...] - Signal to send on reaload.
	//    - PIDFile     string () [/run/prog.pid] - Location of the PID file.
	Option zarray.DefData
}

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

type Ife

type Ife interface {
	Start(s ServiceIfe) error
	Stop(s ServiceIfe) error
}

type ServiceIfe

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

ServiceIfe represents a service that can be run or controlled

func New

func New(i Ife, c *Config) (ServiceIfe, error)

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

type SystemIfe

type SystemIfe interface {
	String() string
	Interactive() bool
	Detect() bool
	New(i Ife, c *Config) (ServiceIfe, error)
}

Jump to

Keyboard shortcuts

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