From e2e20f0b70369fe1898347872c65218e1b44387f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20P=C3=A9rez-Aradros=20Herce?= Date: Mon, 24 Jul 2017 18:24:49 +0200 Subject: [PATCH] Fix config reload when configured for both prospectors and modules (#4736) --- filebeat/crawler/crawler.go | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/filebeat/crawler/crawler.go b/filebeat/crawler/crawler.go index 1e37caa384e6..37a33d50d6ad 100644 --- a/filebeat/crawler/crawler.go +++ b/filebeat/crawler/crawler.go @@ -16,14 +16,15 @@ import ( ) type Crawler struct { - prospectors map[uint64]*prospector.Prospector - prospectorConfigs []*common.Config - out channel.OutleterFactory - wg sync.WaitGroup - reloader *cfgfile.Reloader - once bool - beatVersion string - beatDone chan struct{} + prospectors map[uint64]*prospector.Prospector + prospectorConfigs []*common.Config + out channel.OutleterFactory + wg sync.WaitGroup + modulesReloader *cfgfile.Reloader + prospectorsReloader *cfgfile.Reloader + once bool + beatVersion string + beatDone chan struct{} } func New(out channel.OutleterFactory, prospectorConfigs []*common.Config, beatVersion string, beatDone chan struct{}, once bool) (*Crawler, error) { @@ -54,20 +55,20 @@ func (c *Crawler) Start(r *registrar.Registrar, configProspectors *common.Config if configProspectors.Enabled() { cfgwarn.Beta("Loading separate prospectors is enabled.") - c.reloader = cfgfile.NewReloader(configProspectors) - factory := prospector.NewFactory(c.out, r, c.beatDone) + c.prospectorsReloader = cfgfile.NewReloader(configProspectors) + prospectorsFactory := prospector.NewFactory(c.out, r, c.beatDone) go func() { - c.reloader.Run(factory) + c.prospectorsReloader.Run(prospectorsFactory) }() } if configModules.Enabled() { cfgwarn.Beta("Loading separate modules is enabled.") - c.reloader = cfgfile.NewReloader(configModules) - factory := fileset.NewFactory(c.out, r, c.beatVersion, pipelineLoaderFactory, c.beatDone) + c.modulesReloader = cfgfile.NewReloader(configModules) + modulesFactory := fileset.NewFactory(c.out, r, c.beatVersion, pipelineLoaderFactory, c.beatDone) go func() { - c.reloader.Run(factory) + c.modulesReloader.Run(modulesFactory) }() } @@ -114,8 +115,12 @@ func (c *Crawler) Stop() { asyncWaitStop(p.Stop) } - if c.reloader != nil { - asyncWaitStop(c.reloader.Stop) + if c.prospectorsReloader != nil { + asyncWaitStop(c.prospectorsReloader.Stop) + } + + if c.modulesReloader != nil { + asyncWaitStop(c.modulesReloader.Stop) } c.WaitForCompletion()