-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.config.ts
More file actions
45 lines (39 loc) · 1.22 KB
/
trigger.config.ts
File metadata and controls
45 lines (39 loc) · 1.22 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
42
43
44
45
import { defineConfig } from "@trigger.dev/sdk/v3";
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
const project = process.env.TRIGGER_PROJECT_ID ?? readLocalEnv("TRIGGER_PROJECT_ID");
if (!project) {
throw new Error("TRIGGER_PROJECT_ID must be set to run or deploy Trigger.dev tasks.");
}
export default defineConfig({
project,
runtime: "node",
logLevel: "log",
// The max compute seconds a task is allowed to run. If the task run exceeds this duration, it will be stopped.
// You can override this on an individual task.
// See https://trigger.dev/docs/runs/max-duration
maxDuration: 3600,
retries: {
enabledInDev: true,
default: {
maxAttempts: 3,
minTimeoutInMs: 1000,
maxTimeoutInMs: 10000,
factor: 2,
randomize: true,
},
},
dirs: ["./src/trigger"],
});
function readLocalEnv(name: string) {
const envPath = join(process.cwd(), ".env");
if (!existsSync(envPath)) return undefined;
const line = readFileSync(envPath, "utf8")
.split(/\r?\n/)
.find((entry) => entry.trim().startsWith(`${name}=`));
if (!line) return undefined;
return line
.slice(line.indexOf("=") + 1)
.trim()
.replace(/^['"]|['"]$/g, "");
}