service

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNameFieldRequired is returned when Config.Name is empty.
	ErrNameFieldRequired = errors.New("Config.Name field is required.")
	// ErrNoServiceSystemDetected is returned when no system was detected.
	ErrNoServiceSystemDetected = errors.New("No service system detected.")
	// ErrNotInstalled is returned when the service is not installed
	ErrNotInstalled = errors.New("the service is not installed")
)

Functions

func ServiceInstall

func ServiceInstall(svcName, execPath, dispalyName, serviceStartName, pwd string, args ...string) error

func ServiceStart

func ServiceStart(srcName string) error

func ServiceStop

func ServiceStop(srcName string) error

func ServiceUninstall

func ServiceUninstall(srcName string) error

Types

type Interface

type Interface interface {
	Start() error
	Stop() error
}

type Status

type Status byte
const (
	StatusUnknown Status = iota // Status is unable to be determined due to an error or it was not installed.
	StatusRunning
	StatusStopped
	StatusUninstall
)

func ServiceStatus

func ServiceStatus(srcName string) (Status, error)

status

type WindowsService

type WindowsService struct {
	Name string
	// contains filtered or unexported fields
}

func NewService

func NewService(i Interface, name string) (*WindowsService, error)

func (*WindowsService) Execute

func (ws *WindowsService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32)

func (*WindowsService) Run

func (ws *WindowsService) Run(isDebug bool) error

Notes

Bugs

  • MessageBeep Windows api is broken on Windows 7, so this example does not beep when runs as service on Windows 7.

Directories

Path Synopsis
example
cli

Jump to

Keyboard shortcuts

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