fix: windows service - graceful shutdown of telegraf (#9616)

This commit is contained in:
JC 2021-12-02 22:32:19 +00:00 committed by GitHub
parent 75c48d48d7
commit b954e565cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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 close channel
return nil
}