mgr

package
v0.0.0-...-0df215e Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package mgr can be used to manage Windows service programs. It can be used to install and remove them. It can also start, stop and pause them. The package can query / change current service state and config parameters.

Index

Constants

View Source
const (
	// Service start types.
	StartManual    = windows.SERVICE_DEMAND_START // the service must be started manually
	StartAutomatic = windows.SERVICE_AUTO_START   // the service will start by itself whenever the computer reboots
	StartDisabled  = windows.SERVICE_DISABLED     // the service cannot be started

	// The severity of the error, and action taken,
	// if this service fails to start.
	ErrorCritical = windows.SERVICE_ERROR_CRITICAL
	ErrorIgnore   = windows.SERVICE_ERROR_IGNORE
	ErrorNormal   = windows.SERVICE_ERROR_NORMAL
	ErrorSevere   = windows.SERVICE_ERROR_SEVERE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServiceType      uint32
	StartType        uint32
	ErrorControl     uint32
	BinaryPathName   string // fully qualified path to the service binary file, can also include arguments for an auto-start service
	LoadOrderGroup   string
	TagId            uint32
	Dependencies     []string
	ServiceStartName string // name of the account under which the service should run
	DisplayName      string
	Password         string
	Description      string
}

type Mgr

type Mgr struct {
	Handle windows.Handle
}

Mgr is used to manage Windows service.

func Connect

func Connect() (*Mgr, error)

Connect establishes a connection to the service control manager.

func ConnectRemote

func ConnectRemote(host string) (*Mgr, error)

ConnectRemote establishes a connection to the service control manager on computer named host.

func (*Mgr) CreateService

func (m *Mgr) CreateService(name, exepath string, c Config, args ...string) (*Service, error)

CreateService installs new service name on the system. The service will be executed by running exepath binary. Use config c to specify service parameters. If service StartType is set to StartAutomatic, args will be passed to svc.Handle.Execute.

func (*Mgr) Disconnect

func (m *Mgr) Disconnect() error

Disconnect closes connection to the service control manager m.

func (*Mgr) OpenService

func (m *Mgr) OpenService(name string) (*Service, error)

OpenService retrieves access to service name, so it can be interrogated and controlled.

type Service

type Service struct {
	Name   string
	Handle windows.Handle
}

Service is used to access Windows service.

func (*Service) Close

func (s *Service) Close() error

Close relinquish access to the service s.

func (*Service) Config

func (s *Service) Config() (Config, error)

Config retrieves service s configuration paramteres.

func (*Service) Control

func (s *Service) Control(c svc.Cmd) (svc.Status, error)

Control sends state change request c to the servce s.

func (*Service) Delete

func (s *Service) Delete() error

Delete marks service s for deletion from the service control manager database.

func (*Service) Query

func (s *Service) Query() (svc.Status, error)

Query returns current status of service s.

func (*Service) Start

func (s *Service) Start(args ...string) error

Start starts service s. args will be passed to svc.Handler.Execute.

func (*Service) UpdateConfig

func (s *Service) UpdateConfig(c Config) error

UpdateConfig updates service s configuration parameters.

Jump to

Keyboard shortcuts

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