mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
`// +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
32 lines
871 B
Go
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
|
|
}
|