Skip to content

Commit

Permalink
start config watcher goroutine last
Browse files Browse the repository at this point in the history
  • Loading branch information
benjirewis committed Dec 11, 2024
1 parent 6846f82 commit 305174e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions web/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,17 @@ func (s *robotServer) serveWeb(ctx context.Context, cfg *config.Config) (err err
err = multierr.Combine(err, myRobot.Close(context.Background()))
}()

// Start web service with `minimalProcessedConfig`, then `Reconfigure` robot
// to have `fullProcessedConfig`.
options, err := s.createWebOptions(minimalProcessedConfig)
if err != nil {
return err
}
if err := web.RunWeb(ctx, myRobot, options, s.logger); err != nil {
return err
}
myRobot.Reconfigure(ctx, fullProcessedConfig)

// watch for and deliver changes to the robot
watcher, err := config.NewWatcher(ctx, cfg, s.logger.Sublogger("config"))
if err != nil {
Expand Down Expand Up @@ -494,17 +505,6 @@ func (s *robotServer) serveWeb(ctx context.Context, cfg *config.Config) (err err
<-onWatchDone
}()
defer cancel()

// As mentioned above, start web service with `minimalProcessedConfig`. Then,
// `Reconfigure` robot to have `fullProcessedConfig`.
options, err := s.createWebOptions(minimalProcessedConfig)
if err != nil {
return err
}
if err := web.RunWeb(ctx, myRobot, options, s.logger); err != nil {
return err
}
myRobot.Reconfigure(ctx, fullProcessedConfig)
return nil
}

Expand Down

0 comments on commit 305174e

Please sign in to comment.