svc

package
v0.0.0-...-ce73089 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ControlAction      = [6]string{"start", "stop", "restart", "install", "uninstall", "status"}
	ControlActionUsage = [6]string{"启动", "停止", "重启", "安装", "卸载", "状态"}
	ErrUnknownAction   = errors.New("无效的控制命令")
)

Functions

This section is empty.

Types

type Control

type Control func(command string) (string, error)

func New

func New(prog Service) Control

func (Control) Control

func (c Control) Control(command string) (string, error)

func (Control) Run

func (c Control) Run(command string)

type Service

type Service struct {
	Name        string   // Required name of the service. No spaces suggested.
	DisplayName string   // Display name, spaces allowed.
	Description string   // Long description of service.
	UserName    string   // Run as username.
	Arguments   []string // Run with arguments.

	// Optional field to specify the executable for service.
	// If empty the current executable is used.
	Executable string

	// Array of service dependencies.
	// Not yet fully implemented on Linux or OS X:
	//  1. Support linux-systemd dependencies, just put each full line as the
	//     element of the string array, such as
	//     "After=network.target syslog.target"
	//     "Requires=syslog.target"
	//     Note, such lines will be directly appended into the [Unit] of
	//     the generated service config file, will not check their correctness.
	Dependencies []string

	// The following fields are not supported on Windows.
	WorkingDirectory string // Initial working directory.
	ChRoot           string
	Option           map[string]any // System specific options.

	EnvVars map[string]string

	Init func() error                //block exec
	Run  func(context.Context) error //non-block exec
}

Jump to

Keyboard shortcuts

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