mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-22 20:56:36 +00:00
use IsWindowsService to detect if running as service
Signed-off-by: James Sturtevant <jstur@microsoft.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package main
|
package main
|
||||||
@@ -324,13 +325,13 @@ func main() {
|
|||||||
|
|
||||||
initWbem()
|
initWbem()
|
||||||
|
|
||||||
isInteractive, err := svc.IsAnInteractiveSession()
|
isService, err := svc.IsWindowsService()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stopCh := make(chan bool)
|
stopCh := make(chan bool)
|
||||||
if !isInteractive {
|
if isService {
|
||||||
go func() {
|
go func() {
|
||||||
err = svc.Run(serviceName, &windowsExporterService{stopCh: stopCh})
|
err = svc.Run(serviceName, &windowsExporterService{stopCh: stopCh})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user