@@ -928,37 +928,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
928
928
options .StatsBatcher = batcher
929
929
defer closeBatcher ()
930
930
931
- // Manage notifications.
932
- var (
933
- notificationsCfg = options .DeploymentValues .Notifications
934
- notificationsManager * notifications.Manager
935
- )
936
-
937
- metrics := notifications .NewMetrics (options .PrometheusRegistry )
938
- helpers := templateHelpers (options )
939
-
940
- // The enqueuer is responsible for enqueueing notifications to the given store.
941
- enqueuer , err := notifications .NewStoreEnqueuer (notificationsCfg , options .Database , helpers , logger .Named ("notifications.enqueuer" ), quartz .NewReal ())
942
- if err != nil {
943
- return xerrors .Errorf ("failed to instantiate notification store enqueuer: %w" , err )
944
- }
945
- options .NotificationsEnqueuer = enqueuer
946
-
947
- // The notification manager is responsible for:
948
- // - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
949
- // - keeping the store updated with status updates
950
- notificationsManager , err = notifications .NewManager (notificationsCfg , options .Database , options .Pubsub , helpers , metrics , logger .Named ("notifications.manager" ))
951
- if err != nil {
952
- return xerrors .Errorf ("failed to instantiate notification manager: %w" , err )
953
- }
954
-
955
- // nolint:gocritic // We need to run the manager in a notifier context.
956
- notificationsManager .Run (dbauthz .AsNotifier (ctx ))
957
-
958
- // Run report generator to distribute periodic reports.
959
- notificationReportGenerator := reports .NewReportGenerator (ctx , logger .Named ("notifications.report_generator" ), options .Database , options .NotificationsEnqueuer , quartz .NewReal ())
960
- defer notificationReportGenerator .Close ()
961
-
962
931
// We use a separate coderAPICloser so the Enterprise API
963
932
// can have its own close functions. This is cleaner
964
933
// than abstracting the Coder API itself.
@@ -1006,6 +975,37 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
1006
975
return xerrors .Errorf ("write config url: %w" , err )
1007
976
}
1008
977
978
+ // Manage notifications.
979
+ var (
980
+ notificationsCfg = options .DeploymentValues .Notifications
981
+ notificationsManager * notifications.Manager
982
+ )
983
+
984
+ metrics := notifications .NewMetrics (options .PrometheusRegistry )
985
+ helpers := templateHelpers (options )
986
+
987
+ // The enqueuer is responsible for enqueueing notifications to the given store.
988
+ enqueuer , err := notifications .NewStoreEnqueuer (notificationsCfg , options .Database , options .Pubsub , helpers , logger .Named ("notifications.enqueuer" ), quartz .NewReal ())
989
+ if err != nil {
990
+ return xerrors .Errorf ("failed to instantiate notification store enqueuer: %w" , err )
991
+ }
992
+ options .NotificationsEnqueuer = enqueuer
993
+
994
+ // The notification manager is responsible for:
995
+ // - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
996
+ // - keeping the store updated with status updates
997
+ notificationsManager , err = notifications .NewManager (notificationsCfg , options .Database , options .Pubsub , helpers , metrics , logger .Named ("notifications.manager" ))
998
+ if err != nil {
999
+ return xerrors .Errorf ("failed to instantiate notification manager: %w" , err )
1000
+ }
1001
+
1002
+ // nolint:gocritic // We need to run the manager in a notifier context.
1003
+ notificationsManager .Run (dbauthz .AsNotifier (ctx ))
1004
+
1005
+ // Run report generator to distribute periodic reports.
1006
+ notificationReportGenerator := reports .NewReportGenerator (ctx , logger .Named ("notifications.report_generator" ), options .Database , options .NotificationsEnqueuer , quartz .NewReal ())
1007
+ defer notificationReportGenerator .Close ()
1008
+
1009
1009
// Since errCh only has one buffered slot, all routines
1010
1010
// sending on it must be wrapped in a select/default to
1011
1011
// avoid leaving dangling goroutines waiting for the
0 commit comments