Files
Dmitrii AnoshinandGitHub 53307a9ce5 Remove the obsolete +build directive (#9304)
`// +build` was replaced with `//go:build` directive in Go 1.17. The
`+build` can be removed since we support only 1.20 and 1.21
2024-01-17 09:56:14 -08:00

32 lines
871 B
Go

// Code generated by "go.opentelemetry.io/collector/cmd/builder". DO NOT EDIT.
//go:build windows
package main
import (
"errors"
"fmt"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
"go.opentelemetry.io/collector/otelcol"
)
func run(params otelcol.CollectorSettings) error {
// No need to supply service name when startup is invoked through
// the Service Control Manager directly.
if err := svc.Run("", otelcol.NewSvcHandler(params)); err != nil {
if errors.Is(err, windows.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
// Per https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatchera#return-value
// this means that the process is not running as a service, so run interactively.
return runInteractive(params)
}
return fmt.Errorf("failed to start collector server: %w", err)
}
return nil
}