Documentation
¶
Overview ¶
Package windows provides a set of functions to manage Windows services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServiceManager ¶
type ServiceManager interface {
StopAllAgentServices(ctx context.Context) error
StartAgentServices(ctx context.Context) error
RestartAgentServices(ctx context.Context) error
}
ServiceManager interface abstracts all service management operations
Could generalize for arbitrary services later, but we only need the Agent services for now.
type WinServiceManager ¶
type WinServiceManager struct {
// contains filtered or unexported fields
}
WinServiceManager implements ServiceManager using the SystemAPI interface
func NewWinServiceManager ¶
func NewWinServiceManager() *WinServiceManager
NewWinServiceManager creates a new WinServiceManager with real implementations
func NewWinServiceManagerWithAPI ¶
func NewWinServiceManagerWithAPI(api systemAPI) *WinServiceManager
NewWinServiceManagerWithAPI creates a new WinServiceManager with a custom SystemAPI (for testing)
func (*WinServiceManager) RestartAgentServices ¶
func (w *WinServiceManager) RestartAgentServices(ctx context.Context) (err error)
RestartAgentServices combines StopAllAgentServices and StartAgentServices.
Ignores errors from StopAllAgentServices and will always attempt to start the services again. Returns an error if any of the services failed to start.
func (*WinServiceManager) StartAgentServices ¶
func (w *WinServiceManager) StartAgentServices(ctx context.Context) (err error)
StartAgentServices starts the Agent service, expecting it to start all other services as well.
func (*WinServiceManager) StopAllAgentServices ¶
func (w *WinServiceManager) StopAllAgentServices(ctx context.Context) (err error)
StopAllAgentServices stops the Agent service, expecting it to stop all other services as well. After attempting to stop the Agent service, it will force stop any remaining services.
Returns nil if the Agent service does not exist.