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.
This commit is contained in:
Dennis Bellinger 2016-07-25 11:42:53 -04:00
parent 1d43fbebcf
commit a0b25c6dba
1 changed files with 25 additions and 22 deletions

View File

@ -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,6 +326,7 @@ func (p *program) Stop(s service.Service) error {
}
func main() {
if runtime.GOOS == "windows" {
svcConfig := &service.Config{
Name: "telegraf",
DisplayName: "Telegraf Data Collector Service",
@ -333,9 +334,7 @@ func main() {
"another series of plugins.",
}
if runtime.GOOS == "windows" {
svcConfig.Arguments = []string{"-config", "C:\\telegraf\\telegraf.conf"}
}
prg := &program{}
s, err := service.New(prg, svcConfig)
@ -350,4 +349,8 @@ func main() {
if err != nil {
logger.Error(err)
}
} else {
stop = make(chan struct{})
reloadLoop(stop, nil)
}
}