Exit after running --test without requiring --console (#5631)

This commit is contained in:
Daniel Nelson 2019-03-26 18:17:27 -07:00 committed by GitHub
parent be26ef6f9b
commit c57ba6110d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -342,7 +342,7 @@ func main() {
log.Println("Telegraf version already configured to: " + internal.Version()) log.Println("Telegraf version already configured to: " + internal.Version())
} }
if runtime.GOOS == "windows" && !(*fRunAsConsole) { if runtime.GOOS == "windows" && windowsRunAsService() {
svcConfig := &service.Config{ svcConfig := &service.Config{
Name: *fServiceName, Name: *fServiceName,
DisplayName: "Telegraf Data Collector Service", DisplayName: "Telegraf Data Collector Service",
@ -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()
}