Skip to content

Commit

Permalink
Exit after running --test without requiring --console (influxdata#5631)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and Mathieu Lecarme committed Apr 17, 2020
1 parent 380a2af commit b26b997
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func main() {
log.Println("Telegraf version already configured to: " + internal.Version())
}

if runtime.GOOS == "windows" && !(*fRunAsConsole) {
if runtime.GOOS == "windows" && windowsRunAsService() {
svcConfig := &service.Config{
Name: *fServiceName,
DisplayName: "Telegraf Data Collector Service",
Expand Down Expand Up @@ -392,3 +392,16 @@ func main() {
)
}
}

// Return true if Telegraf should create a Windows service.
func windowsRunAsService() bool {
if *fService != "" {
return true
}

if *fRunAsConsole {
return false
}

return !service.Interactive()
}

0 comments on commit b26b997

Please sign in to comment.