Skip to content

Commit

Permalink
Merged service.go into telegraf.go
Browse files Browse the repository at this point in the history
Due to compilation issues on Windows, moved the code from service.go
into telegraf.go and removed service.go entirely.
  • Loading branch information
butitsnotme committed Jul 18, 2016
1 parent 35f5e62 commit 101dbd2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 53 deletions.
53 changes: 0 additions & 53 deletions cmd/telegraf/service.go

This file was deleted.

46 changes: 46 additions & 0 deletions cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ Examples:
telegraf -config telegraf.conf -input-filter cpu:mem -output-filter influxdb
`

var logger service.Logger

var stop chan struct{}

var srvc service.Service

type program struct{}


func reloadLoop(stop chan struct{}, s service.Service) {
defer func() {
if service.Interactive() {
Expand Down Expand Up @@ -301,3 +310,40 @@ func usageExit(rc int) {
fmt.Println(usage)
os.Exit(rc)
}

func (p *program) Start(s service.Service) error {
srvc = s
go p.run()
return nil
}
func (p *program) run() {
stop = make(chan struct{})
reloadLoop(stop, srvc)
}
func (p *program) Stop(s service.Service) error {
close(stop)
return nil
}

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.",
}

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)
}
}

0 comments on commit 101dbd2

Please sign in to comment.