service

package
v0.0.0-...-7220889 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package service allows running Go programs as Window Services.

To run a program as a Windows Service, it must call `StartServiceCtrlDispatcher` and other Windows APIs to manage its state.

The service package handles this for Windows, and is a no-op on other platforms.

Based on the golang supplemental package example: https://pkg.go.dev/golang.org/x/sys/windows/svc/example

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(s *Service) int

Types

type Service

type Service struct {
	// Run the service. On Windows, will be in a new goroutine.
	// Return value will be returned by service.Run()
	Start func() int

	// Only used on Windows. Must cause the Start() function to return, running in another goroutine.
	Stop func()
}

A Service is passed to Run, which will check if it is being run as a Service on Windows and call the Windows APIs as appropriate. If not, only the Start function will be called.

Jump to

Keyboard shortcuts

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