mgr

package
v0.0.0-...-7afe134 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2014 License: MIT Imports: 4 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, pause and so on. It can query current service state. It can query service config parameters and change them.

Index

Constants

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

	// The severity of the error, and action taken,
	// if this service fails to start.
	ErrorCritical = winapi.SERVICE_ERROR_CRITICAL
	ErrorIgnore   = winapi.SERVICE_ERROR_IGNORE
	ErrorNormal   = winapi.SERVICE_ERROR_NORMAL
	ErrorSevere   = winapi.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
	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 syscall.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) (*Service, error)

CreateService installs new service name on the system. The service will be executed by running exepath binary, while service settings are specified in config c.

func (*Mgr) Disconnect

func (m *Mgr) Disconnect() error

Disconnect closes connection m to servise control manager.

func (*Mgr) OpenService

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

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

type Service

type Service struct {
	Name   string
	Handle syscall.Handle
}

Service is used to access Windows service.

func (*Service) Close

func (s *Service) Close() error

Close relinquish access to service s.

func (*Service) Config

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

func (*Service) Control

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

Control sends state change request c to 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.

func (*Service) UpdateConfig

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

Jump to

Keyboard shortcuts

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