Skip to content

Commit

Permalink
fix: only log subsystem start when actually started
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Nov 22, 2024
1 parent dcf4779 commit a72fbd0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/daemon/subsystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ func (s *Subsystem) Start(ctx context.Context, g *errgroup.Group) error {
ctx = authz.AddSubjectToContext(ctx, &authz.Superuser{Username: s.Name})

op := func() (err error) {
start := func(ctx context.Context) error {
s.V(1).Info("started subsystem", "name", s.Name)
return s.System.Start(ctx)
}
if s.Exclusive {
// block on getting an exclusive lock
err = s.DB.WaitAndLock(ctx, *s.LockID, func(ctx context.Context) error {
return s.System.Start(ctx)
})
err = s.DB.WaitAndLock(ctx, *s.LockID, start)
} else {
err = s.System.Start(ctx)
err = start(ctx)
}
if ctx.Err() != nil {
// don't return an error if subsystem was terminated via a
Expand All @@ -79,6 +81,5 @@ func (s *Subsystem) Start(ctx context.Context, g *errgroup.Group) error {
s.Error(err, "restarting subsystem", "name", s.Name, "backoff", next)
})
})
s.V(1).Info("started subsystem", "name", s.Name)
return nil
}

0 comments on commit a72fbd0

Please sign in to comment.