From a0b25c6dbaa86c1cd2e19e8891050720e6b362ca Mon Sep 17 00:00:00 2001 From: Dennis Bellinger Date: Mon, 25 Jul 2016 11:42:53 -0400 Subject: [PATCH] Removed service library on all but Windows The service library [kardianos/service](github.com/kardianos/service) has been disabled on all platforms but windows, as there is already existing infrastructure for other platforms. --- cmd/telegraf/telegraf.go | 47 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index 56f230071..f4da55e60 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -200,7 +200,7 @@ func reloadLoop(stop chan struct{}, s service.Service) { return } - if *fService != "" { + if *fService != "" && runtime.GOOS == "windows" { err := service.Control(s, *fService) if err != nil { log.Fatal(err) @@ -326,28 +326,31 @@ func (p *program) Stop(s service.Service) error { } func main() { - svcConfig := &service.Config{ - Name: "telegraf", - DisplayName: "Telegraf Data Collector Service", - Description: "Collects data using a series of plugins and publishes it to" + - "another series of plugins.", - } - if runtime.GOOS == "windows" { - svcConfig.Arguments = []string{"-config", "C:\\telegraf\\telegraf.conf"} - } + svcConfig := &service.Config{ + Name: "telegraf", + DisplayName: "Telegraf Data Collector Service", + Description: "Collects data using a series of plugins and publishes it to" + + "another series of plugins.", + } - prg := &program{} - s, err := service.New(prg, svcConfig) - if err != nil { - log.Fatal(err) - } - logger, err = s.Logger(nil) - if err != nil { - log.Fatal(err) - } - err = s.Run() - if err != nil { - logger.Error(err) + svcConfig.Arguments = []string{"-config", "C:\\telegraf\\telegraf.conf"} + + prg := &program{} + s, err := service.New(prg, svcConfig) + if err != nil { + log.Fatal(err) + } + logger, err = s.Logger(nil) + if err != nil { + log.Fatal(err) + } + err = s.Run() + if err != nil { + logger.Error(err) + } + } else { + stop = make(chan struct{}) + reloadLoop(stop, nil) } }