Skip to content

Commit

Permalink
Wait for reloadLoop goroutine to finish before allowing main goroutin…
Browse files Browse the repository at this point in the history
…e to end when running as Windows service
  • Loading branch information
jhychan committed Oct 13, 2021
1 parent 432b30d commit c2eb751
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/telegraf/telegraf_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ func (p *program) run() {
p.inputFilters,
p.outputFilters,
)
close(stop)
}
func (p *program) Stop(s service.Service) error {
close(stop)
var empty struct{}
stop <- empty // signal reloadLoop to finish (context cancel)
<-stop // wait for reloadLoop to finish and channel to close
return nil
}

Expand Down

0 comments on commit c2eb751

Please sign in to comment.