daemon

package
v1.1.103 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedSystem = errors.New(1900, "unsupported system")
	ErrNeedSystemd       = errors.New(1901, "need systemd to install the service")
	ErrRootPrivileges    = errors.New(1902, "requires root user privileges. Possibly use 'sudo'")
	ErrAlreadyInstalled  = errors.Newf(1903, "%s service has already been installed")
	ErrCurrentlyRunning  = errors.Newf(1904, "%s service is running and cannot be removed")
	ErrNotInstalled      = errors.Newf(1905, "%s service is not installed")
	ErrAlreadyRunning    = errors.Newf(1906, "%s service is already running")
	ErrAlreadyStopped    = errors.Newf(1907, "%s service is already stopped")
)

Errors that are hit while managing an Agent's service

Functions

func ExecPath

func ExecPath() (string, error)

ExecPath tries to get executable path

Types

type Daemon

type Daemon interface {
	// GetTemplate - gets service config template
	GetTemplate() string

	// SetTemplate - sets service config template
	SetTemplate(string) error

	// Install the service into the system
	Install(args ...string) (string, error)

	// Update the service definition on the system
	Update(args ...string) (string, error)

	// Remove the service and all corresponding files from the system
	Remove() (string, error)

	// Start the service
	Start() (string, error)

	// Stop the service
	Stop() (string, error)

	// Status - check the service status
	Status() (string, error)

	// Enable - sets the service to persist reboots
	Enable() (string, error)

	// Logs - gets the service logs
	Logs() (string, error)

	// Run - run executable service
	Run(e Executable) (string, error)

	// SetEnvFile - sets the environment file argument for generating the agent command
	SetEnvFile(string) error

	// SetUser - sets the user that executes the service
	SetUser(string) error

	// setGroup - sets the group that executes the service
	SetGroup(string) error

	// GetServiceName - gets the name of the service
	GetServiceName() string
}

Daemon interface has a standard set of methods/commands

func New

func New(name, description string, dependencies ...string) (Daemon, error)

New - Create a new daemon

name: name of the service

description: any explanation, what is the service, its purpose

type Executable

type Executable interface {
	// Start - non-blocking start service
	Start()
	// Stop - non-blocking stop service
	Stop()
	// Run - blocking run service
	Run()
}

Executable interface defines controlling methods of executable service

Jump to

Keyboard shortcuts

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