daemon

package
v1.1.33 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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