Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit593c5a0

Browse files
committed
Reorder notification manager to avoid race with CreateInMemoryTaggedProvisionerDaemon
Signed-off-by: Danny Kopping <danny@coder.com>
1 parentaf8d833 commit593c5a0

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

‎cli/server.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,33 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
943943
returnxerrors.Errorf("write config url: %w",err)
944944
}
945945

946+
// Manage notifications.
947+
cfg:=options.DeploymentValues.Notifications
948+
metrics:=notifications.NewMetrics(options.PrometheusRegistry)
949+
helpers:=templateHelpers(options)
950+
951+
// The enqueuer is responsible for enqueueing notifications to the given store.
952+
enqueuer,err:=notifications.NewStoreEnqueuer(cfg,options.Database,helpers,logger.Named("notifications.enqueuer"),quartz.NewReal())
953+
iferr!=nil {
954+
returnxerrors.Errorf("failed to instantiate notification store enqueuer: %w",err)
955+
}
956+
options.NotificationsEnqueuer=enqueuer
957+
958+
// The notification manager is responsible for:
959+
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
960+
// - keeping the store updated with status updates
961+
notificationsManager,err:=notifications.NewManager(cfg,options.Database,helpers,metrics,logger.Named("notifications.manager"))
962+
iferr!=nil {
963+
returnxerrors.Errorf("failed to instantiate notification manager: %w",err)
964+
}
965+
966+
// nolint:gocritic // TODO: create own role.
967+
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx))
968+
969+
// Run report generator to distribute periodic reports.
970+
notificationReportGenerator:=reports.NewReportGenerator(ctx,logger.Named("notifications.report_generator"),options.Database,options.NotificationsEnqueuer,quartz.NewReal())
971+
defernotificationReportGenerator.Close()
972+
946973
// Since errCh only has one buffered slot, all routines
947974
// sending on it must be wrapped in a select/default to
948975
// avoid leaving dangling goroutines waiting for the
@@ -999,33 +1026,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
9991026
options.WorkspaceUsageTracker=tracker
10001027
defertracker.Close()
10011028

1002-
// Manage notifications.
1003-
cfg:=options.DeploymentValues.Notifications
1004-
metrics:=notifications.NewMetrics(options.PrometheusRegistry)
1005-
helpers:=templateHelpers(options)
1006-
1007-
// The enqueuer is responsible for enqueueing notifications to the given store.
1008-
enqueuer,err:=notifications.NewStoreEnqueuer(cfg,options.Database,helpers,logger.Named("notifications.enqueuer"),quartz.NewReal())
1009-
iferr!=nil {
1010-
returnxerrors.Errorf("failed to instantiate notification store enqueuer: %w",err)
1011-
}
1012-
options.NotificationsEnqueuer=enqueuer
1013-
1014-
// The notification manager is responsible for:
1015-
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
1016-
// - keeping the store updated with status updates
1017-
notificationsManager,err:=notifications.NewManager(cfg,options.Database,helpers,metrics,logger.Named("notifications.manager"))
1018-
iferr!=nil {
1019-
returnxerrors.Errorf("failed to instantiate notification manager: %w",err)
1020-
}
1021-
1022-
// nolint:gocritic // TODO: create own role.
1023-
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx))
1024-
1025-
// Run report generator to distribute periodic reports.
1026-
notificationReportGenerator:=reports.NewReportGenerator(ctx,logger.Named("notifications.report_generator"),options.Database,options.NotificationsEnqueuer,quartz.NewReal())
1027-
defernotificationReportGenerator.Close()
1028-
10291029
// Wrap the server in middleware that redirects to the access URL if
10301030
// the request is not to a local IP.
10311031
varhandler http.Handler=coderAPI.RootHandler

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp