Help us shape the future of Go! Take the 2026 Go Developer Survey

service

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const LibEnvironment = "LD_LIBRARY_PATH"

LibEnvironment environment variable setting search for system libraries

Variables

View Source
var SystemPath = "/usr/lib/systemd/system"

SystemPath system path for systemd configurations

Functions

func ControlService

func ControlService(env *Parameters, c Cmd, to State) error

ControlService control the service

func DecryptPassword

func DecryptPassword(data, key string) (string, error)

DecryptPassword decrypt installation password

func DisableService

func DisableService(env *Parameters) error

DisableService disable the service

func EnableService

func EnableService(env *Parameters) error

EnableService enable the service

func InstallService

func InstallService(env *Parameters) error

InstallService install the service

func IsService

func IsService() bool

IsService return if the process context is part of a service

func RemoveService

func RemoveService(env *Parameters) error

RemoveService remove the service

func RunService

func RunService(env *Parameters, isDebug bool)

RunService run the service

func ShutdownService

func ShutdownService(env *Parameters) error

ShutdownService shutdown service

func StartService

func StartService(env *Parameters) error

StartService start the service

func StatusService

func StatusService(env *Parameters) error

StatusService disable the status of the service

func StopService

func StopService(env *Parameters) error

StopService stop the service

Types

type Cmd

type Cmd byte

Cmd command to be executed

const (
	// Start start the service
	Start Cmd = iota
	// Stop stop the service
	Stop
	// Pause pause the service (not on Unix)
	Pause
	// Continue continue the service (not on Unix)
	Continue
	// Status status of the service
	Status
)

type Interface

type Interface interface {
	Run(env *Parameters) error
	Shutdown(env *Parameters) error
}

Interface service interface for services

type Parameters

type Parameters struct {
	Name         string
	DisplayName  string
	AppPath      string
	Description  string
	Path         string
	WrapperName  string
	Environments []string
	Parameters   []string
	ID           int
	User         string
	Password     string
	Group        string
	ServiceFct   Interface
	Cmd          *exec.Cmd
}

Parameters installation environment settings

func InitService

func InitService(name, appName, description string, svc Interface) *Parameters

InitService initialize installation environment structure

func (*Parameters) AdaptConfigure

func (env *Parameters) AdaptConfigure(name string) error

AdaptConfigure load installation configuration and adapt service parameters to the installation parameters

func (*Parameters) AppDirectory

func (env *Parameters) AppDirectory() string

AppDirectory provide path of installation

func (*Parameters) FileName

func (env *Parameters) FileName() string

FileName used file name system file name plist

func (*Parameters) ParseInstallXML

func (env *Parameters) ParseInstallXML(fileName string) error

ParseInstallXML parse install XML file

func (*Parameters) PrepareService

func (env *Parameters) PrepareService() error

PrepareService generate installation configuration and write service parameters to the installation file

func (*Parameters) ServiceName

func (env *Parameters) ServiceName() string

ServiceName used file name system name

func (*Parameters) StartCommand

func (env *Parameters) StartCommand(command string, arg []string) error

StartCommand execute application in given environment

type Properties

type Properties struct {
	XMLName xml.Name `xml:"properties"`
	Entries []struct {
		Key  string `xml:"key,attr"`
		Name string `xml:",chardata"`
	} `xml:"entry"`
}

Properties installation properties

type State

type State byte

State state of the service

const (
	// Running service is running
	Running State = iota
	// Stopped service is stopped
	Stopped
	// Paused service is paused
	Paused
)

Jump to

Keyboard shortcuts

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