-
-
Notifications
You must be signed in to change notification settings - Fork 367
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
41 lines (33 loc) · 1.08 KB
/
instrumentation.ts
File metadata and controls
41 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { env } from "./env";
import { isCloud, isEmailCleanupEnabled } from "./utils/common";
let initialized = false;
/**
* Add things here to be executed during server startup.
*
* more details here: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
*/
export async function register() {
// eslint-disable-next-line turbo/no-undeclared-env-vars
if (process.env.NEXT_RUNTIME === "nodejs" && !initialized) {
console.log("Registering instrumentation");
const { EmailQueueService } = await import(
"~/server/service/email-queue-service"
);
await EmailQueueService.init();
/**
* Send usage data to Stripe
*/
if (isCloud()) {
await import("~/server/jobs/usage-job");
}
await import("~/server/jobs/domain-verification-job");
if (isEmailCleanupEnabled()) {
await import("~/server/jobs/cleanup-email-bodies");
}
const { CampaignSchedulerService } = await import(
"~/server/jobs/campaign-scheduler-job"
);
await CampaignSchedulerService.start();
initialized = true;
}
}