diff --git a/internal/pkg/service/service_other.go b/internal/pkg/service/service_other.go index 4a4c5f9..4b67082 100644 --- a/internal/pkg/service/service_other.go +++ b/internal/pkg/service/service_other.go @@ -3,23 +3,25 @@ //go:build !windows +// Package service provides Windows service integration for the runner. +// On non-Windows platforms, these functions are no-ops. package service import ( "context" ) -// IsWindowsService returns false on non-Windows platforms +// IsWindowsService returns false on non-Windows platforms. func IsWindowsService() bool { return false } -// RunAsService is a no-op on non-Windows platforms -func RunAsService(serviceName string, run func(ctx context.Context)) error { +// RunAsService is a no-op on non-Windows platforms. +func RunAsService(_ string, _ func(ctx context.Context)) error { return nil } -// GetServiceName returns empty on non-Windows platforms +// GetServiceName returns empty on non-Windows platforms. func GetServiceName() string { return "" } diff --git a/internal/pkg/service/service_windows.go b/internal/pkg/service/service_windows.go index cf01e26..686ab42 100644 --- a/internal/pkg/service/service_windows.go +++ b/internal/pkg/service/service_windows.go @@ -3,6 +3,7 @@ //go:build windows +// Package service provides Windows service integration for the runner. package service import ( @@ -15,14 +16,14 @@ import ( "golang.org/x/sys/windows/svc" ) -// runnerService implements svc.Handler for Windows service management +// runnerService implements svc.Handler for Windows service management. type runnerService struct { ctx context.Context cancel context.CancelFunc } -// Execute is called by the Windows Service Control Manager -func (s *runnerService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { +// Execute is called by the Windows Service Control Manager. +func (s *runnerService) Execute(_ []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown changes <- svc.Status{State: svc.StartPending} @@ -53,10 +54,10 @@ loop: } changes <- svc.Status{State: svc.StopPending} - return + return false, 0 } -// IsWindowsService returns true if the process is running as a Windows service +// IsWindowsService returns true if the process is running as a Windows service. func IsWindowsService() bool { // Check if we're running interactively isInteractive, err := svc.IsWindowsService() @@ -67,7 +68,7 @@ func IsWindowsService() bool { return isInteractive } -// RunAsService runs the application as a Windows service +// RunAsService runs the application as a Windows service. func RunAsService(serviceName string, run func(ctx context.Context)) error { ctx, cancel := context.WithCancel(context.Background()) @@ -84,7 +85,7 @@ func RunAsService(serviceName string, run func(ctx context.Context)) error { return nil } -// GetServiceName returns the service name from environment or default +// GetServiceName returns the service name from environment or default. func GetServiceName() string { if name := os.Getenv("GITEA_RUNNER_SERVICE_NAME"); name != "" { return name