Skip to content

Commit

Permalink
Fix config reload when configured for both prospectors and modules (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
exekias authored and tsg committed Jul 24, 2017
1 parent 6711e4d commit e2e20f0
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions filebeat/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}()
}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e2e20f0

Please sign in to comment.