Documentation ¶
Overview ¶
Package svc provides everything required to build Windows service.
Index ¶
Constants ¶
const ( Stopped = State(winapi.SERVICE_STOPPED) StartPending = State(winapi.SERVICE_START_PENDING) StopPending = State(winapi.SERVICE_STOP_PENDING) Running = State(winapi.SERVICE_RUNNING) ContinuePending = State(winapi.SERVICE_CONTINUE_PENDING) PausePending = State(winapi.SERVICE_PAUSE_PENDING) Paused = State(winapi.SERVICE_PAUSED) )
const ( Stop = Cmd(winapi.SERVICE_CONTROL_STOP) Pause = Cmd(winapi.SERVICE_CONTROL_PAUSE) Continue = Cmd(winapi.SERVICE_CONTROL_CONTINUE) Interrogate = Cmd(winapi.SERVICE_CONTROL_INTERROGATE) Shutdown = Cmd(winapi.SERVICE_CONTROL_SHUTDOWN) )
const ( AcceptStop = Accepted(winapi.SERVICE_ACCEPT_STOP) AcceptShutdown = Accepted(winapi.SERVICE_ACCEPT_SHUTDOWN) AcceptPauseAndContinue = Accepted(winapi.SERVICE_ACCEPT_PAUSE_CONTINUE) )
Variables ¶
This section is empty.
Functions ¶
func IsAnIinteractiveSession ¶
IsAnIinteractiveSession is a misspelled version of IsAnInteractiveSession. Do not use. It is kept here so we do not break existing code.
func IsAnInteractiveSession ¶
IsAnInteractiveSession determines if calling process is running interactively. It queries the process token for membership in the Interactive group. http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s
Types ¶
type Accepted ¶
type Accepted uint32
Accepted is used to describe commands accepted by the service. Note, that Interrogate is always accepted.
type ChangeRequest ¶
ChangeRequest is sent to service Handler to request service status change.
type Cmd ¶
type Cmd uint32
Cmd represents service state change request. It is sent to a service by the service manager, and should be actioned upon by the service.
type Handler ¶
type Handler interface { // Execute will be called by the package code at the start of // the service, and the service will exit once Execute completes. // Inside Execute you must read service change requests from r and // act accordingly. You must keep service control manager up to date // about state of your service by writing into s as required. // args contains argument strings passed to the service. // You can provide service exit code in exitCode return parameter, // with 0 being "no error". You can also indicate if exit code, // if any, is service specific or not by using svcSpecificEC // parameter. Execute(args []string, r <-chan ChangeRequest, s chan<- Status) (svcSpecificEC bool, exitCode uint32) }
Handler is the interface that must be implemented to build Windows service.
type State ¶
type State uint32
State describes service execution state (Stopped, Running and so on).
type Status ¶
type Status struct { State State Accepts Accepted CheckPoint uint32 // used to report progress during a lengthy operation WaitHint uint32 // estimated time required for a pending operation, in milliseconds }
Status combines State and Accepted commands to fully describe running service.
Notes ¶
Bugs ¶
There is no mechanism to run multiple services inside one single executable. Perhaps, it can be overcome by using RegisterServiceCtrlHandlerEx Windows api.