-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrigger.config.ts
74 lines (68 loc) · 2.59 KB
/
trigger.config.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { StartMikroORMForTrigger } from './src/trigger/reuseables/orm';
import { FsInstrumentation } from '@opentelemetry/instrumentation-fs';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
import { additionalFiles } from '@trigger.dev/build/extensions/core';
import { emitDecoratorMetadata } from '@trigger.dev/build/extensions/typescript';
import { defineConfig, logger, usage } from '@trigger.dev/sdk/v3';
export default defineConfig({
project: 'proj_pnqbfgxmeuaytlevhxap',
maxDuration: 7200, // 2 hours
build: {
external: [
'@as-integrations/fastify',
'@apollo/gateway',
'@nestjs/mongoose',
'@nestjs/sequelize',
'@sentry/profiling-node',
'@nestjs/apollo',
'@nestjs/terminus',
'fsevents',
],
extensions: [emitDecoratorMetadata()],
},
logLevel: 'log',
retries: {
enabledInDev: true,
default: {
maxAttempts: 3,
minTimeoutInMs: 1000,
maxTimeoutInMs: 10000,
factor: 2,
randomize: true,
},
},
instrumentations: [
new PgInstrumentation(),
new UndiciInstrumentation(),
new HttpInstrumentation(),
new FsInstrumentation(),
],
init: async (payload, { ctx }) => {
logger.info(`Initialized on machine "${ctx.machine?.name ?? 'Unknown'}"`, { ctx });
await StartMikroORMForTrigger();
},
onSuccess: async (payload, output, params) => {
let costInDollars = 'NOT_KNOWN';
const currentUsage = usage.getCurrent();
if (currentUsage.totalCostInCents) {
costInDollars = `$${(currentUsage.totalCostInCents / 100).toLocaleString('en-US', {
minimumFractionDigits: 10,
useGrouping: false,
})}`;
}
logger.info(`[Costing] This task completed successfully, with a total cost of ${costInDollars}`);
},
onFailure: async (payload, error, params) => {
let costInDollars = 'NOT_KNOWN';
const currentUsage = usage.getCurrent();
if (currentUsage.totalCostInCents) {
costInDollars = `$${(currentUsage.totalCostInCents / 100).toLocaleString('en-US', {
minimumFractionDigits: 10,
useGrouping: false,
})}`;
}
logger.error(`[Costing] This task failed, with a total cost of ${costInDollars}`);
},
});