serivce

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

README

go-service

Let your Go application serve as a system service.

Supported system

OS Status
Linux Ready
Windows Need-to-fix
macOS Need-to-fix

Documentation

Index

Constants

View Source
const (
	SystemCtl = "systemctl"
)

Variables

This section is empty.

Functions

func EmptyThenDefault

func EmptyThenDefault(val, defVal string, args ...any) string

EmptyThenDefault return the default value if the val is empty

Types

type CommonService

type CommonService struct {
	ID          string
	Name        string
	Description string
	Command     string
	Args        []string

	Execer fakeruntime.Execer
	// contains filtered or unexported fields
}

type ContainerOption

type ContainerOption struct {
	ID, Name         string
	Image, Tag, Pull string
	Writer           io.Writer
}

type ServerFeatureOption

type ServerFeatureOption struct {
	ID      string
	Name    string
	Command string
	Args    []string
}

type Service

type Service interface {
	Start() (string, error)     // start the service
	Stop() (string, error)      // stop the service gracefully
	Restart() (string, error)   // restart the service gracefully
	Status() (string, error)    // status of the service
	Install() (string, error)   // install the service
	Uninstall() (string, error) // uninstall the service
	Available() bool
}

Service is the interface of service

func GetAvailableService

func GetAvailableService(mode ServiceMode,
	containerOption ContainerOption, service CommonService) (svc Service, err error)

func NewContainerService

func NewContainerService(service CommonService, client string,
	containerOption ContainerOption) (svc Service)

func NewService

func NewService(svc CommonService) (service Service, err error)

type ServiceMode

type ServiceMode string
const (
	ServiceModeOS        ServiceMode = "os"
	ServiceModeContainer ServiceMode = "container"
	ServiceModePodman    ServiceMode = "podman"
	ServiceModeDocker    ServiceMode = "docker"
)

func (ServiceMode) All

func (s ServiceMode) All() []ServiceMode

func (ServiceMode) String

func (s ServiceMode) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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