systemctl

package
v1.10.32-lts Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServiceNotFound  = errors.New("service not found")
	ErrDiscoveryTimeout = errors.New("service discovery timeout for: %w")
	ErrServiceDiscovery = errors.New("service discovery failed for: %w")
	ErrNoValidService   = errors.New("no valid service found for: %w")
)
View Source
var (
	BinaryPath         = "/usr/local/bin" // 1panl service default path
	ErrServiceNotExist = errors.New("service does not exist")
)

Functions

func Disable

func Disable(serviceName string) error

func Enable

func Enable(serviceName string) error

func FileExist

func FileExist(path string) bool

func GetServiceName

func GetServiceName(serviceName string) (string, error)

func GetServicePath

func GetServicePath(serviceName string) (string, error)

func InitializeGlobalManager

func InitializeGlobalManager() (err error)

func InitializeServiceDiscovery

func InitializeServiceDiscovery()

func IsActive

func IsActive(serviceName string) (bool, error)

func IsEnable added in v1.8.0

func IsEnable(serviceName string) (bool, error)

func IsExist

func IsExist(serviceName string) (bool, error)

func RegisterServiceAliases

func RegisterServiceAliases(aliases map[string][]string)

func Restart

func Restart(serviceName string) error

func Start

func Start(serviceName string) error

func Stop

func Stop(serviceName string) error

func ViewConfig

func ViewConfig(path string, opt ConfigOption) (string, error)

Types

type CommandError

type CommandError struct {
	Cmd    string
	Err    error
	Output string
}

func (CommandError) Error

func (e CommandError) Error() string

type ConfigOption

type ConfigOption struct {
	TailLines string
}

type LogOption

type LogOption struct {
	TailLines string
}

type ServiceConfig

type ServiceConfig struct {
	ServiceName map[string]string
}

type ServiceHandler

type ServiceHandler struct {
	// contains filtered or unexported fields
}

func DefaultHandler

func DefaultHandler(serviceName string) (*ServiceHandler, error)

func NewServiceHandler

func NewServiceHandler(serviceNames map[string]string) *ServiceHandler

func (*ServiceHandler) DisableService

func (h *ServiceHandler) DisableService() (ServiceResult, error)

func (*ServiceHandler) EnableService

func (h *ServiceHandler) EnableService() (ServiceResult, error)

func (*ServiceHandler) ExecuteAction

func (h *ServiceHandler) ExecuteAction(action string) (ServiceResult, error)

func (*ServiceHandler) GetServiceName

func (h *ServiceHandler) GetServiceName() string

func (*ServiceHandler) GetServicePath

func (h *ServiceHandler) GetServicePath() (string, error)

func (*ServiceHandler) IsActive

func (h *ServiceHandler) IsActive() (ServiceStatus, error)

func (*ServiceHandler) IsEnabled

func (h *ServiceHandler) IsEnabled() (ServiceStatus, error)

func (*ServiceHandler) IsExists

func (h *ServiceHandler) IsExists() (ServiceStatus, error)

func (*ServiceHandler) ManagerName

func (h *ServiceHandler) ManagerName() string

func (*ServiceHandler) RestartService

func (h *ServiceHandler) RestartService() (ServiceResult, error)

func (*ServiceHandler) StartService

func (h *ServiceHandler) StartService() (ServiceResult, error)

func (*ServiceHandler) StopService

func (h *ServiceHandler) StopService() (ServiceResult, error)

type ServiceIsActive

type ServiceIsActive struct {
	IsActive bool   `json:"isActive"`
	Output   string `json:"output"`
}

type ServiceIsEnabled

type ServiceIsEnabled struct {
	IsEnabled bool   `json:"isEnabled"`
	Output    string `json:"output"`
}

type ServiceManager

type ServiceManager interface {
	Name() string
	IsAvailable() bool
	ServiceExists(*ServiceConfig) (bool, error)
	BuildCommand(string, *ServiceConfig) ([]string, error)
	ParseStatus(string, *ServiceConfig, string) (bool, error)
	FindServices(string) ([]string, error)
}

func GetGlobalManager

func GetGlobalManager() ServiceManager

type ServiceResult

type ServiceResult struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Output  string `json:"output"`
}

func CustomAction

func CustomAction(action string, serviceName string) (ServiceResult, error)

type ServiceStatus

type ServiceStatus struct {
	IsActive  bool   `json:"isActive"`
	IsEnabled bool   `json:"isEnabled"`
	IsExists  bool   `json:"isExists"`
	Output    string `json:"output"`
}

Jump to

Keyboard shortcuts

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