Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServiceReturn ¶
ServiceReturn computes service exit code for a given error.
Error instances carry both values directly. Any instances of syscall.Errno are treated as non-service-specific errors. All other non-nil errors return service-specific exit code 1.
Types ¶
type Environment ¶
type Environment struct { // R is the channel where the system sends service change requests. R <-chan svc.ChangeRequest // C is the channel where the service can send updated status. S chan<- svc.Status // L is an interface for logging from Windows services. L is either a // debug.ConsoleLog or eventlog.Log depending on how the service is started. L debug.Log }
Environment contains windows service command and control channels.
type ManagementFlags ¶ added in v0.1.3
type ManagementFlags uint32
ManagementFlags controls which of the management commands are enabled.
const ( // SubsetMode indicates that not all management commands should be enabled. // When SubsetMode is not enabled then all remaining flags are ignored and // all commands are enabled automatically. SubsetMode ManagementFlags = 1 << iota // PauseAndContinue indicates that "pause" and "continue" commands should be // enabled. // // This only makes sense if the service is able to respond to the // corresponding commands and advertises support through the accept mask. PauseAndContinue // InstallAndRemove indicates that "install" and "remove" commands should be // enabled. InstallAndRemove // StartAndStop indicates that "start" and "stop" commands should be // enabled. StartAndStop // InteractiveDebug indicates that the "debug" command should be enabled. InteractiveDebug )
type Wrapper ¶
type Wrapper struct { ServiceName string ServiceCmd cmdr.Cmd InstallConfig mgr.Config // ManagementFlags controls which management commands are enabled. // // The zero value offers backwards compatibility where all commands are // enabled. To enable a subset use SubsetMode together with a mask // representing the desired commands. ManagementFlags ManagementFlags }
Wrapper allows running commands as Windows services.
The wrapper offers a set of standard sub-commands for installing, removing, pausing, continuing and debugging a Windows service. The wrapped command must use Env to retrieve service command and control channels from the context.
While any command may be wrapped and ran as a service, commands should actively drain the command channel to behave properly.
func (*Wrapper) Run ¶
Run starts a Windows service or routes execution to management commands.
Depending on the execution environment, one of two things happens. When Run is called from a Windows service process, it runs the ServiceCmd command directly. When running outside of a Windows service, for example from an interactive terminal, Run offers a set of management commands.
The command can return any error. Errors posing as ServiceError can be used to convey service specific error codes.