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 return
} }
if *fService != "" { if *fService != "" && runtime.GOOS == "windows" {
err := service.Control(s, *fService) err := service.Control(s, *fService)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@ -326,28 +326,31 @@ func (p *program) Stop(s service.Service) error {
} }
func main() { 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" { 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{} svcConfig.Arguments = []string{"-config", "C:\\telegraf\\telegraf.conf"}
s, err := service.New(prg, svcConfig)
if err != nil { prg := &program{}
log.Fatal(err) s, err := service.New(prg, svcConfig)
} if err != nil {
logger, err = s.Logger(nil) log.Fatal(err)
if err != nil { }
log.Fatal(err) logger, err = s.Logger(nil)
} if err != nil {
err = s.Run() log.Fatal(err)
if err != nil { }
logger.Error(err) err = s.Run()
if err != nil {
logger.Error(err)
}
} else {
stop = make(chan struct{})
reloadLoop(stop, nil)
} }
} }