Debian Codegraph @

cmd/otelcorecol/main_windows.go

raw
1 // Code generated by "go.opentelemetry.io/collector/cmd/builder". DO NOT EDIT.
2
3 //go:build windows
4
5 package main
6
7 import (
8 "errors"
9 "fmt"
10
11 "golang.org/x/sys/windows"
12 "golang.org/x/sys/windows/svc"
13
14 "go.opentelemetry.io/collector/otelcol"
15 )
16
17 func run(params otelcol.CollectorSettings) error {
18 // No need to supply service name when startup is invoked through
19 // the Service Control Manager directly.
20 if err := svc.Run("", otelcol.NewSvcHandler(params)); err != nil {
21 if errors.Is(err, windows.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
22 // Per https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatchera#return-value
23 // this means that the process is not running as a service, so run interactively.
24 return runInteractive(params)
25 }
26
27 return fmt.Errorf("failed to start collector server: %w", err)
28 }
29
30 return nil
31 }