-
Notifications
You must be signed in to change notification settings - Fork 537
Expand file tree
/
Copy pathmain_windows.go
More file actions
29 lines (23 loc) · 869 Bytes
/
main_windows.go
File metadata and controls
29 lines (23 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 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
}