Initialize base context when creating New worker and not at start (#3294)

This commit is contained in:
Todd authored and GitHub committed 2023-06-07 11:42:16 -07:00
1 parent 43f3c6bd68
commit 5a68d789ec
1 file changed
+3 -3
+3 -3
View File
@@ -188,7 +188,10 @@ func New(ctx context.Context, conf *Config) (*Worker, error) {
metric.InitializeClusterClientCollectors(conf.PrometheusRegisterer)
initializeReverseGrpcClientCollectors(conf.PrometheusRegisterer)
baseContext, baseCancel := context.WithCancel(context.Background())
w := &Worker{
baseContext: baseContext,
baseCancel: baseCancel,
conf: conf,
logger: conf.Logger.Named("worker"),
started: ua.NewBool(false),
@@ -358,9 +361,6 @@ func (w *Worker) Reload(ctx context.Context, newConf *config.Config) {
func (w *Worker) Start() error {
const op = "worker.(Worker).Start"
w.baseContext, w.baseCancel = context.WithCancel(context.Background())
if w.started.Load() {
event.WriteSysEvent(w.baseContext, op, "already started, skipping")
return nil