Skip to content

Commit

Permalink
updates: perform implicit run
Browse files Browse the repository at this point in the history
when moving libvuln to non-blocking the initial updater run was removed.
this caused libvuln not to issue a run of the update manager until the
first interval tick which by default is 30 minutes.

this update adds a implicit call to run before setting up the
time.Tickers.

Signed-off-by: ldelossa <[email protected]>
  • Loading branch information
ldelossa authored and ldelossa committed Feb 5, 2021
1 parent b95d984 commit 966de96
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libvuln/updates/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func NewManager(ctx context.Context, store vulnstore.Updater, pool *pgxpool.Pool
//
// Start is designed to be ran as a go routine.
// Cancel the provided ctx to end the updater loop.
//
// Start must only be called once between context
// cancelations.
func (m *Manager) Start(ctx context.Context) error {
log := zerolog.Ctx(ctx).With().
Str("component", "libvuln/updates/Manager.Start").
Expand All @@ -108,9 +111,12 @@ func (m *Manager) Start(ctx context.Context) error {
}
log.Info().Str("interval", m.interval.String()).Msg("starting background updates")

// perform the initial run
m.Run(ctx)

// perform run on every tick
t := time.NewTicker(m.interval)
defer t.Stop()

for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 966de96

Please sign in to comment.