trigger.dev 4.0.0-v4-beta.1 → 4.0.0-v4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/dev/devSupervisor.js +14 -10
- package/dist/esm/dev/devSupervisor.js.map +1 -1
- package/dist/esm/entryPoints/dev-run-controller.js +6 -6
- package/dist/esm/entryPoints/dev-run-controller.js.map +1 -1
- package/dist/esm/entryPoints/managed/controller.d.ts +50 -0
- package/dist/esm/entryPoints/managed/controller.js +441 -0
- package/dist/esm/entryPoints/managed/controller.js.map +1 -0
- package/dist/esm/entryPoints/managed/env.d.ts +170 -0
- package/dist/esm/entryPoints/managed/env.js +191 -0
- package/dist/esm/entryPoints/managed/env.js.map +1 -0
- package/dist/esm/entryPoints/managed/execution.d.ts +94 -0
- package/dist/esm/entryPoints/managed/execution.js +638 -0
- package/dist/esm/entryPoints/managed/execution.js.map +1 -0
- package/dist/esm/entryPoints/managed/heartbeat.d.ts +23 -0
- package/dist/esm/entryPoints/managed/heartbeat.js +68 -0
- package/dist/esm/entryPoints/managed/heartbeat.js.map +1 -0
- package/dist/esm/entryPoints/managed/logger.d.ts +19 -0
- package/dist/esm/entryPoints/managed/logger.js +31 -0
- package/dist/esm/entryPoints/managed/logger.js.map +1 -0
- package/dist/esm/entryPoints/managed/overrides.d.ts +16 -0
- package/dist/esm/entryPoints/managed/overrides.js +17 -0
- package/dist/esm/entryPoints/managed/overrides.js.map +1 -0
- package/dist/esm/entryPoints/managed/poller.d.ts +26 -0
- package/dist/esm/entryPoints/managed/poller.js +94 -0
- package/dist/esm/entryPoints/managed/poller.js.map +1 -0
- package/dist/esm/entryPoints/managed-run-controller.js +8 -1347
- package/dist/esm/entryPoints/managed-run-controller.js.map +1 -1
- package/dist/esm/executions/taskRunProcess.d.ts +2 -2
- package/dist/esm/executions/taskRunProcess.js +1 -1
- package/dist/esm/executions/taskRunProcess.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { WarmStartClient, WORKLOAD_HEADERS, WorkloadHttpClient, } from "@trigger.dev/core/v3/workers";
|
|
2
|
+
import { io } from "socket.io-client";
|
|
3
|
+
import { RunnerEnv } from "./env.js";
|
|
4
|
+
import { RunLogger } from "./logger.js";
|
|
5
|
+
import { RunExecution } from "./execution.js";
|
|
6
|
+
import { tryCatch } from "@trigger.dev/core/utils";
|
|
7
|
+
export class ManagedRunController {
|
|
8
|
+
env;
|
|
9
|
+
workerManifest;
|
|
10
|
+
httpClient;
|
|
11
|
+
warmStartClient;
|
|
12
|
+
socket;
|
|
13
|
+
logger;
|
|
14
|
+
warmStartCount = 0;
|
|
15
|
+
restoreCount = 0;
|
|
16
|
+
currentExecution = null;
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
const env = new RunnerEnv(opts.env);
|
|
19
|
+
this.env = env;
|
|
20
|
+
this.workerManifest = opts.workerManifest;
|
|
21
|
+
this.httpClient = new WorkloadHttpClient({
|
|
22
|
+
workerApiUrl: this.workerApiUrl,
|
|
23
|
+
runnerId: this.runnerId,
|
|
24
|
+
deploymentId: env.TRIGGER_DEPLOYMENT_ID,
|
|
25
|
+
deploymentVersion: env.TRIGGER_DEPLOYMENT_VERSION,
|
|
26
|
+
projectRef: env.TRIGGER_PROJECT_REF,
|
|
27
|
+
});
|
|
28
|
+
this.logger = new RunLogger({
|
|
29
|
+
httpClient: this.httpClient,
|
|
30
|
+
env,
|
|
31
|
+
});
|
|
32
|
+
const properties = {
|
|
33
|
+
...env.raw,
|
|
34
|
+
TRIGGER_POD_SCHEDULED_AT_MS: env.TRIGGER_POD_SCHEDULED_AT_MS.toISOString(),
|
|
35
|
+
TRIGGER_DEQUEUED_AT_MS: env.TRIGGER_DEQUEUED_AT_MS.toISOString(),
|
|
36
|
+
};
|
|
37
|
+
this.sendDebugLog({
|
|
38
|
+
runId: env.TRIGGER_RUN_ID,
|
|
39
|
+
message: "Creating run controller",
|
|
40
|
+
properties,
|
|
41
|
+
});
|
|
42
|
+
if (env.TRIGGER_WARM_START_URL) {
|
|
43
|
+
this.warmStartClient = new WarmStartClient({
|
|
44
|
+
apiUrl: new URL(env.TRIGGER_WARM_START_URL),
|
|
45
|
+
controllerId: env.TRIGGER_WORKLOAD_CONTROLLER_ID,
|
|
46
|
+
deploymentId: env.TRIGGER_DEPLOYMENT_ID,
|
|
47
|
+
deploymentVersion: env.TRIGGER_DEPLOYMENT_VERSION,
|
|
48
|
+
machineCpu: env.TRIGGER_MACHINE_CPU,
|
|
49
|
+
machineMemory: env.TRIGGER_MACHINE_MEMORY,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Websocket notifications are only an optimisation so we don't need to wait for a successful connection
|
|
53
|
+
this.socket = this.createSupervisorSocket();
|
|
54
|
+
process.on("SIGTERM", async () => {
|
|
55
|
+
this.sendDebugLog({
|
|
56
|
+
runId: this.runFriendlyId,
|
|
57
|
+
message: "Received SIGTERM, stopping worker",
|
|
58
|
+
});
|
|
59
|
+
await this.stop();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
get metrics() {
|
|
63
|
+
return {
|
|
64
|
+
warmStartCount: this.warmStartCount,
|
|
65
|
+
restoreCount: this.restoreCount,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
get runnerId() {
|
|
69
|
+
return this.env.TRIGGER_RUNNER_ID;
|
|
70
|
+
}
|
|
71
|
+
get successExitCode() {
|
|
72
|
+
return this.env.TRIGGER_SUCCESS_EXIT_CODE;
|
|
73
|
+
}
|
|
74
|
+
get failureExitCode() {
|
|
75
|
+
return this.env.TRIGGER_FAILURE_EXIT_CODE;
|
|
76
|
+
}
|
|
77
|
+
get workerApiUrl() {
|
|
78
|
+
return this.env.TRIGGER_SUPERVISOR_API_URL;
|
|
79
|
+
}
|
|
80
|
+
get workerInstanceName() {
|
|
81
|
+
return this.env.TRIGGER_WORKER_INSTANCE_NAME;
|
|
82
|
+
}
|
|
83
|
+
subscribeToRunNotifications(runFriendlyId, snapshotFriendlyId) {
|
|
84
|
+
this.socket.emit("run:start", {
|
|
85
|
+
version: "1",
|
|
86
|
+
run: {
|
|
87
|
+
friendlyId: runFriendlyId,
|
|
88
|
+
},
|
|
89
|
+
snapshot: {
|
|
90
|
+
friendlyId: snapshotFriendlyId,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
unsubscribeFromRunNotifications(runFriendlyId, snapshotFriendlyId) {
|
|
95
|
+
this.socket.emit("run:stop", {
|
|
96
|
+
version: "1",
|
|
97
|
+
run: {
|
|
98
|
+
friendlyId: runFriendlyId,
|
|
99
|
+
},
|
|
100
|
+
snapshot: {
|
|
101
|
+
friendlyId: snapshotFriendlyId,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
get runFriendlyId() {
|
|
106
|
+
return this.currentExecution?.runFriendlyId;
|
|
107
|
+
}
|
|
108
|
+
get snapshotFriendlyId() {
|
|
109
|
+
return this.currentExecution?.currentSnapshotFriendlyId;
|
|
110
|
+
}
|
|
111
|
+
lockedRunExecution = null;
|
|
112
|
+
async startRunExecution({ runFriendlyId, snapshotFriendlyId, dequeuedAt, podScheduledAt, isWarmStart, previousRunId, }) {
|
|
113
|
+
this.sendDebugLog({
|
|
114
|
+
runId: runFriendlyId,
|
|
115
|
+
message: "startAndExecuteRunAttempt()",
|
|
116
|
+
properties: { previousRunId },
|
|
117
|
+
});
|
|
118
|
+
if (this.lockedRunExecution) {
|
|
119
|
+
this.sendDebugLog({
|
|
120
|
+
runId: runFriendlyId,
|
|
121
|
+
message: "startAndExecuteRunAttempt: execution already locked",
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const execution = async () => {
|
|
126
|
+
if (!this.currentExecution || !this.currentExecution.isPreparedForNextRun) {
|
|
127
|
+
this.currentExecution = new RunExecution({
|
|
128
|
+
workerManifest: this.workerManifest,
|
|
129
|
+
env: this.env,
|
|
130
|
+
httpClient: this.httpClient,
|
|
131
|
+
logger: this.logger,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// Subscribe to run notifications
|
|
135
|
+
this.subscribeToRunNotifications(runFriendlyId, snapshotFriendlyId);
|
|
136
|
+
// We're prepared for the next run so we can start executing
|
|
137
|
+
await this.currentExecution.execute({
|
|
138
|
+
runFriendlyId,
|
|
139
|
+
snapshotFriendlyId,
|
|
140
|
+
dequeuedAt,
|
|
141
|
+
podScheduledAt,
|
|
142
|
+
isWarmStart,
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
this.lockedRunExecution = execution();
|
|
146
|
+
const [error] = await tryCatch(this.lockedRunExecution);
|
|
147
|
+
if (error) {
|
|
148
|
+
this.sendDebugLog({
|
|
149
|
+
runId: runFriendlyId,
|
|
150
|
+
message: "Error during execution",
|
|
151
|
+
properties: { error: error.message },
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const metrics = this.currentExecution?.metrics;
|
|
155
|
+
if (metrics?.restoreCount) {
|
|
156
|
+
this.restoreCount += metrics.restoreCount;
|
|
157
|
+
}
|
|
158
|
+
this.lockedRunExecution = null;
|
|
159
|
+
this.unsubscribeFromRunNotifications(runFriendlyId, snapshotFriendlyId);
|
|
160
|
+
this.waitForNextRun();
|
|
161
|
+
}
|
|
162
|
+
waitForNextRunLock = false;
|
|
163
|
+
/**
|
|
164
|
+
* This will eagerly create a new run execution. It will never throw, but may exit
|
|
165
|
+
* the process on any errors or when no runs are available after the configured duration.
|
|
166
|
+
*/
|
|
167
|
+
async waitForNextRun() {
|
|
168
|
+
this.sendDebugLog({
|
|
169
|
+
runId: this.runFriendlyId,
|
|
170
|
+
message: "waitForNextRun()",
|
|
171
|
+
});
|
|
172
|
+
if (this.waitForNextRunLock) {
|
|
173
|
+
this.sendDebugLog({
|
|
174
|
+
runId: this.runFriendlyId,
|
|
175
|
+
message: "waitForNextRun: already in progress, skipping",
|
|
176
|
+
});
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (this.lockedRunExecution) {
|
|
180
|
+
this.sendDebugLog({
|
|
181
|
+
runId: this.runFriendlyId,
|
|
182
|
+
message: "waitForNextRun: execution locked, skipping",
|
|
183
|
+
});
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.waitForNextRunLock = true;
|
|
187
|
+
try {
|
|
188
|
+
if (!this.warmStartClient) {
|
|
189
|
+
this.sendDebugLog({
|
|
190
|
+
runId: this.runFriendlyId,
|
|
191
|
+
message: "waitForNextRun: warm starts disabled, shutting down",
|
|
192
|
+
});
|
|
193
|
+
this.exitProcess(this.successExitCode);
|
|
194
|
+
}
|
|
195
|
+
const previousRunId = this.runFriendlyId;
|
|
196
|
+
if (this.currentExecution?.taskRunEnv) {
|
|
197
|
+
this.sendDebugLog({
|
|
198
|
+
runId: this.runFriendlyId,
|
|
199
|
+
message: "waitForNextRun: eagerly recreating task run process",
|
|
200
|
+
});
|
|
201
|
+
const previousTaskRunEnv = this.currentExecution.taskRunEnv;
|
|
202
|
+
this.currentExecution = new RunExecution({
|
|
203
|
+
workerManifest: this.workerManifest,
|
|
204
|
+
env: this.env,
|
|
205
|
+
httpClient: this.httpClient,
|
|
206
|
+
logger: this.logger,
|
|
207
|
+
}).prepareForExecution({
|
|
208
|
+
taskRunEnv: previousTaskRunEnv,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// Check the service is up and get additional warm start config
|
|
212
|
+
const connect = await this.warmStartClient.connect();
|
|
213
|
+
if (!connect.success) {
|
|
214
|
+
this.sendDebugLog({
|
|
215
|
+
runId: this.runFriendlyId,
|
|
216
|
+
message: "waitForNextRun: failed to connect to warm start service",
|
|
217
|
+
properties: {
|
|
218
|
+
warmStartUrl: this.env.TRIGGER_WARM_START_URL,
|
|
219
|
+
error: connect.error,
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
this.exitProcess(this.successExitCode);
|
|
223
|
+
}
|
|
224
|
+
const connectionTimeoutMs = connect.data.connectionTimeoutMs ?? this.env.TRIGGER_WARM_START_CONNECTION_TIMEOUT_MS;
|
|
225
|
+
const keepaliveMs = connect.data.keepaliveMs ?? this.env.TRIGGER_WARM_START_KEEPALIVE_MS;
|
|
226
|
+
const warmStartConfig = {
|
|
227
|
+
connectionTimeoutMs,
|
|
228
|
+
keepaliveMs,
|
|
229
|
+
};
|
|
230
|
+
this.sendDebugLog({
|
|
231
|
+
runId: this.runFriendlyId,
|
|
232
|
+
message: "waitForNextRun: connected to warm start service",
|
|
233
|
+
properties: warmStartConfig,
|
|
234
|
+
});
|
|
235
|
+
if (!connectionTimeoutMs || !keepaliveMs) {
|
|
236
|
+
this.sendDebugLog({
|
|
237
|
+
runId: this.runFriendlyId,
|
|
238
|
+
message: "waitForNextRun: warm starts disabled after connect",
|
|
239
|
+
properties: warmStartConfig,
|
|
240
|
+
});
|
|
241
|
+
this.exitProcess(this.successExitCode);
|
|
242
|
+
}
|
|
243
|
+
const nextRun = await this.warmStartClient.warmStart({
|
|
244
|
+
workerInstanceName: this.workerInstanceName,
|
|
245
|
+
connectionTimeoutMs,
|
|
246
|
+
keepaliveMs,
|
|
247
|
+
});
|
|
248
|
+
if (!nextRun) {
|
|
249
|
+
this.sendDebugLog({
|
|
250
|
+
runId: this.runFriendlyId,
|
|
251
|
+
message: "waitForNextRun: warm start failed, shutting down",
|
|
252
|
+
properties: warmStartConfig,
|
|
253
|
+
});
|
|
254
|
+
this.exitProcess(this.successExitCode);
|
|
255
|
+
}
|
|
256
|
+
this.warmStartCount++;
|
|
257
|
+
this.sendDebugLog({
|
|
258
|
+
runId: this.runFriendlyId,
|
|
259
|
+
message: "waitForNextRun: got next run",
|
|
260
|
+
properties: {
|
|
261
|
+
...warmStartConfig,
|
|
262
|
+
nextRunId: nextRun.run.friendlyId,
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
this.startRunExecution({
|
|
266
|
+
runFriendlyId: nextRun.run.friendlyId,
|
|
267
|
+
snapshotFriendlyId: nextRun.snapshot.friendlyId,
|
|
268
|
+
dequeuedAt: nextRun.dequeuedAt,
|
|
269
|
+
isWarmStart: true,
|
|
270
|
+
previousRunId,
|
|
271
|
+
}).finally(() => { });
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
this.sendDebugLog({
|
|
275
|
+
runId: this.runFriendlyId,
|
|
276
|
+
message: "waitForNextRun: unexpected error",
|
|
277
|
+
properties: { error: error instanceof Error ? error.message : String(error) },
|
|
278
|
+
});
|
|
279
|
+
this.exitProcess(this.failureExitCode);
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
this.waitForNextRunLock = false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
exitProcess(code) {
|
|
286
|
+
this.sendDebugLog({
|
|
287
|
+
runId: this.runFriendlyId,
|
|
288
|
+
message: "Exiting process",
|
|
289
|
+
properties: { code },
|
|
290
|
+
});
|
|
291
|
+
this.currentExecution?.exit();
|
|
292
|
+
process.exit(code);
|
|
293
|
+
}
|
|
294
|
+
createSupervisorSocket() {
|
|
295
|
+
const wsUrl = new URL("/workload", this.workerApiUrl);
|
|
296
|
+
const socket = io(wsUrl.href, {
|
|
297
|
+
transports: ["websocket"],
|
|
298
|
+
extraHeaders: {
|
|
299
|
+
[WORKLOAD_HEADERS.DEPLOYMENT_ID]: this.env.TRIGGER_DEPLOYMENT_ID,
|
|
300
|
+
[WORKLOAD_HEADERS.RUNNER_ID]: this.env.TRIGGER_RUNNER_ID,
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
socket.on("run:notify", async ({ version, run }) => {
|
|
304
|
+
this.sendDebugLog({
|
|
305
|
+
runId: run.friendlyId,
|
|
306
|
+
message: "run:notify received by runner",
|
|
307
|
+
properties: { version, runId: run.friendlyId },
|
|
308
|
+
});
|
|
309
|
+
if (!this.runFriendlyId) {
|
|
310
|
+
this.sendDebugLog({
|
|
311
|
+
runId: run.friendlyId,
|
|
312
|
+
message: "run:notify: ignoring notification, no local run ID",
|
|
313
|
+
properties: {
|
|
314
|
+
currentRunId: this.runFriendlyId,
|
|
315
|
+
currentSnapshotId: this.snapshotFriendlyId,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (run.friendlyId !== this.runFriendlyId) {
|
|
321
|
+
this.sendDebugLog({
|
|
322
|
+
runId: run.friendlyId,
|
|
323
|
+
message: "run:notify: ignoring notification for different run",
|
|
324
|
+
properties: {
|
|
325
|
+
currentRunId: this.runFriendlyId,
|
|
326
|
+
currentSnapshotId: this.snapshotFriendlyId,
|
|
327
|
+
notificationRunId: run.friendlyId,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const latestSnapshot = await this.httpClient.getRunExecutionData(this.runFriendlyId);
|
|
333
|
+
if (!latestSnapshot.success) {
|
|
334
|
+
this.sendDebugLog({
|
|
335
|
+
runId: this.runFriendlyId,
|
|
336
|
+
message: "run:notify: failed to get latest snapshot data",
|
|
337
|
+
properties: {
|
|
338
|
+
currentRunId: this.runFriendlyId,
|
|
339
|
+
currentSnapshotId: this.snapshotFriendlyId,
|
|
340
|
+
error: latestSnapshot.error,
|
|
341
|
+
},
|
|
342
|
+
});
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const runExecutionData = latestSnapshot.data.execution;
|
|
346
|
+
if (!this.currentExecution) {
|
|
347
|
+
this.sendDebugLog({
|
|
348
|
+
runId: runExecutionData.run.friendlyId,
|
|
349
|
+
message: "handleSnapshotChange: no current execution",
|
|
350
|
+
});
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const [error] = await tryCatch(this.currentExecution.handleSnapshotChange(runExecutionData));
|
|
354
|
+
if (error) {
|
|
355
|
+
this.sendDebugLog({
|
|
356
|
+
runId: runExecutionData.run.friendlyId,
|
|
357
|
+
message: "handleSnapshotChange: unexpected error",
|
|
358
|
+
properties: { error: error.message },
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
socket.on("connect", () => {
|
|
363
|
+
this.sendDebugLog({
|
|
364
|
+
runId: this.runFriendlyId,
|
|
365
|
+
message: "Socket connected to supervisor",
|
|
366
|
+
});
|
|
367
|
+
// This should handle the case where we reconnect after being restored
|
|
368
|
+
if (this.runFriendlyId &&
|
|
369
|
+
this.snapshotFriendlyId &&
|
|
370
|
+
this.runFriendlyId !== this.env.TRIGGER_RUN_ID) {
|
|
371
|
+
this.sendDebugLog({
|
|
372
|
+
runId: this.runFriendlyId,
|
|
373
|
+
message: "Subscribing to notifications for in-progress run",
|
|
374
|
+
});
|
|
375
|
+
this.subscribeToRunNotifications(this.runFriendlyId, this.snapshotFriendlyId);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
socket.on("connect_error", (error) => {
|
|
379
|
+
this.sendDebugLog({
|
|
380
|
+
runId: this.runFriendlyId,
|
|
381
|
+
message: "Socket connection error",
|
|
382
|
+
properties: { error: error instanceof Error ? error.message : String(error) },
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
socket.on("disconnect", (reason, description) => {
|
|
386
|
+
this.sendDebugLog({
|
|
387
|
+
runId: this.runFriendlyId,
|
|
388
|
+
message: "Socket disconnected from supervisor",
|
|
389
|
+
properties: { reason, description: description?.toString() },
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
return socket;
|
|
393
|
+
}
|
|
394
|
+
async cancelAttempt(runId) {
|
|
395
|
+
this.sendDebugLog({
|
|
396
|
+
runId,
|
|
397
|
+
message: "cancelling attempt",
|
|
398
|
+
properties: { runId },
|
|
399
|
+
});
|
|
400
|
+
await this.currentExecution?.cancel();
|
|
401
|
+
}
|
|
402
|
+
start() {
|
|
403
|
+
this.sendDebugLog({
|
|
404
|
+
runId: this.runFriendlyId,
|
|
405
|
+
message: "Starting up",
|
|
406
|
+
});
|
|
407
|
+
// If we have run and snapshot IDs, we can start an attempt immediately
|
|
408
|
+
if (this.env.TRIGGER_RUN_ID && this.env.TRIGGER_SNAPSHOT_ID) {
|
|
409
|
+
this.startRunExecution({
|
|
410
|
+
runFriendlyId: this.env.TRIGGER_RUN_ID,
|
|
411
|
+
snapshotFriendlyId: this.env.TRIGGER_SNAPSHOT_ID,
|
|
412
|
+
dequeuedAt: this.env.TRIGGER_DEQUEUED_AT_MS,
|
|
413
|
+
podScheduledAt: this.env.TRIGGER_POD_SCHEDULED_AT_MS,
|
|
414
|
+
}).finally(() => { });
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
// ..otherwise we need to wait for a run
|
|
418
|
+
this.waitForNextRun();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
async stop() {
|
|
422
|
+
this.sendDebugLog({
|
|
423
|
+
runId: this.runFriendlyId,
|
|
424
|
+
message: "Shutting down",
|
|
425
|
+
});
|
|
426
|
+
await this.currentExecution?.cancel();
|
|
427
|
+
this.socket.close();
|
|
428
|
+
}
|
|
429
|
+
sendDebugLog(opts) {
|
|
430
|
+
this.logger.sendDebugLog({
|
|
431
|
+
...opts,
|
|
432
|
+
message: `[controller] ${opts.message}`,
|
|
433
|
+
properties: {
|
|
434
|
+
...opts.properties,
|
|
435
|
+
runnerWarmStartCount: this.warmStartCount,
|
|
436
|
+
runnerRestoreCount: this.restoreCount,
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/entryPoints/managed/controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,gBAAgB,EAEhB,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,EAAE,EAAe,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,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,CAAC;QACtB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,YAAY,CAAC;YAChB,KAAK,EAAE,IAAI,CAAC,aAAa;YACzB,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,YAAY,CAAC,IAAyB;QACpC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACvB,GAAG,IAAI;YACP,OAAO,EAAE,gBAAgB,IAAI,CAAC,OAAO,EAAE;YACvC,UAAU,EAAE;gBACV,GAAG,IAAI,CAAC,UAAU;gBAClB,oBAAoB,EAAE,IAAI,CAAC,cAAc;gBACzC,kBAAkB,EAAE,IAAI,CAAC,YAAY;aACtC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Metadata } from "./overrides.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { EnvObject } from "std-env";
|
|
4
|
+
declare const Env: z.ZodObject<{
|
|
5
|
+
TRIGGER_CONTENT_HASH: z.ZodString;
|
|
6
|
+
TRIGGER_DEPLOYMENT_ID: z.ZodString;
|
|
7
|
+
TRIGGER_DEPLOYMENT_VERSION: z.ZodString;
|
|
8
|
+
TRIGGER_PROJECT_ID: z.ZodString;
|
|
9
|
+
TRIGGER_PROJECT_REF: z.ZodString;
|
|
10
|
+
NODE_ENV: z.ZodDefault<z.ZodString>;
|
|
11
|
+
NODE_EXTRA_CA_CERTS: z.ZodOptional<z.ZodString>;
|
|
12
|
+
TRIGGER_WORKLOAD_CONTROLLER_ID: z.ZodDefault<z.ZodString>;
|
|
13
|
+
TRIGGER_ENV_ID: z.ZodString;
|
|
14
|
+
TRIGGER_RUN_ID: z.ZodOptional<z.ZodString>;
|
|
15
|
+
TRIGGER_SNAPSHOT_ID: z.ZodOptional<z.ZodString>;
|
|
16
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: z.ZodString;
|
|
17
|
+
TRIGGER_WARM_START_URL: z.ZodOptional<z.ZodString>;
|
|
18
|
+
TRIGGER_WARM_START_CONNECTION_TIMEOUT_MS: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
TRIGGER_WARM_START_KEEPALIVE_MS: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
TRIGGER_MACHINE_CPU: z.ZodDefault<z.ZodString>;
|
|
21
|
+
TRIGGER_MACHINE_MEMORY: z.ZodDefault<z.ZodString>;
|
|
22
|
+
TRIGGER_RUNNER_ID: z.ZodString;
|
|
23
|
+
TRIGGER_METADATA_URL: z.ZodOptional<z.ZodString>;
|
|
24
|
+
TRIGGER_PRE_SUSPEND_WAIT_MS: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
TRIGGER_POD_SCHEDULED_AT_MS: z.ZodPipeline<z.ZodEffects<z.ZodString, Date, string>, z.ZodDate>;
|
|
26
|
+
TRIGGER_DEQUEUED_AT_MS: z.ZodPipeline<z.ZodEffects<z.ZodString, Date, string>, z.ZodDate>;
|
|
27
|
+
TRIGGER_SUPERVISOR_API_PROTOCOL: z.ZodEnum<["http", "https"]>;
|
|
28
|
+
TRIGGER_SUPERVISOR_API_DOMAIN: z.ZodString;
|
|
29
|
+
TRIGGER_SUPERVISOR_API_PORT: z.ZodNumber;
|
|
30
|
+
TRIGGER_WORKER_INSTANCE_NAME: z.ZodString;
|
|
31
|
+
TRIGGER_HEARTBEAT_INTERVAL_SECONDS: z.ZodDefault<z.ZodNumber>;
|
|
32
|
+
TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS: z.ZodDefault<z.ZodNumber>;
|
|
33
|
+
TRIGGER_SUCCESS_EXIT_CODE: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
TRIGGER_FAILURE_EXIT_CODE: z.ZodDefault<z.ZodNumber>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: string;
|
|
37
|
+
NODE_ENV: string;
|
|
38
|
+
TRIGGER_DEPLOYMENT_VERSION: string;
|
|
39
|
+
TRIGGER_PROJECT_REF: string;
|
|
40
|
+
TRIGGER_DEPLOYMENT_ID: string;
|
|
41
|
+
TRIGGER_CONTENT_HASH: string;
|
|
42
|
+
TRIGGER_PROJECT_ID: string;
|
|
43
|
+
TRIGGER_WORKLOAD_CONTROLLER_ID: string;
|
|
44
|
+
TRIGGER_ENV_ID: string;
|
|
45
|
+
TRIGGER_WARM_START_CONNECTION_TIMEOUT_MS: number;
|
|
46
|
+
TRIGGER_WARM_START_KEEPALIVE_MS: number;
|
|
47
|
+
TRIGGER_MACHINE_CPU: string;
|
|
48
|
+
TRIGGER_MACHINE_MEMORY: string;
|
|
49
|
+
TRIGGER_RUNNER_ID: string;
|
|
50
|
+
TRIGGER_PRE_SUSPEND_WAIT_MS: number;
|
|
51
|
+
TRIGGER_POD_SCHEDULED_AT_MS: Date;
|
|
52
|
+
TRIGGER_DEQUEUED_AT_MS: Date;
|
|
53
|
+
TRIGGER_SUPERVISOR_API_PROTOCOL: "http" | "https";
|
|
54
|
+
TRIGGER_SUPERVISOR_API_DOMAIN: string;
|
|
55
|
+
TRIGGER_SUPERVISOR_API_PORT: number;
|
|
56
|
+
TRIGGER_WORKER_INSTANCE_NAME: string;
|
|
57
|
+
TRIGGER_HEARTBEAT_INTERVAL_SECONDS: number;
|
|
58
|
+
TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS: number;
|
|
59
|
+
TRIGGER_SUCCESS_EXIT_CODE: number;
|
|
60
|
+
TRIGGER_FAILURE_EXIT_CODE: number;
|
|
61
|
+
NODE_EXTRA_CA_CERTS?: string | undefined;
|
|
62
|
+
TRIGGER_RUN_ID?: string | undefined;
|
|
63
|
+
TRIGGER_SNAPSHOT_ID?: string | undefined;
|
|
64
|
+
TRIGGER_WARM_START_URL?: string | undefined;
|
|
65
|
+
TRIGGER_METADATA_URL?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: string;
|
|
68
|
+
TRIGGER_DEPLOYMENT_VERSION: string;
|
|
69
|
+
TRIGGER_PROJECT_REF: string;
|
|
70
|
+
TRIGGER_DEPLOYMENT_ID: string;
|
|
71
|
+
TRIGGER_CONTENT_HASH: string;
|
|
72
|
+
TRIGGER_PROJECT_ID: string;
|
|
73
|
+
TRIGGER_ENV_ID: string;
|
|
74
|
+
TRIGGER_RUNNER_ID: string;
|
|
75
|
+
TRIGGER_POD_SCHEDULED_AT_MS: string;
|
|
76
|
+
TRIGGER_DEQUEUED_AT_MS: string;
|
|
77
|
+
TRIGGER_SUPERVISOR_API_PROTOCOL: "http" | "https";
|
|
78
|
+
TRIGGER_SUPERVISOR_API_DOMAIN: string;
|
|
79
|
+
TRIGGER_SUPERVISOR_API_PORT: number;
|
|
80
|
+
TRIGGER_WORKER_INSTANCE_NAME: string;
|
|
81
|
+
NODE_ENV?: string | undefined;
|
|
82
|
+
NODE_EXTRA_CA_CERTS?: string | undefined;
|
|
83
|
+
TRIGGER_WORKLOAD_CONTROLLER_ID?: string | undefined;
|
|
84
|
+
TRIGGER_RUN_ID?: string | undefined;
|
|
85
|
+
TRIGGER_SNAPSHOT_ID?: string | undefined;
|
|
86
|
+
TRIGGER_WARM_START_URL?: string | undefined;
|
|
87
|
+
TRIGGER_WARM_START_CONNECTION_TIMEOUT_MS?: number | undefined;
|
|
88
|
+
TRIGGER_WARM_START_KEEPALIVE_MS?: number | undefined;
|
|
89
|
+
TRIGGER_MACHINE_CPU?: string | undefined;
|
|
90
|
+
TRIGGER_MACHINE_MEMORY?: string | undefined;
|
|
91
|
+
TRIGGER_METADATA_URL?: string | undefined;
|
|
92
|
+
TRIGGER_PRE_SUSPEND_WAIT_MS?: number | undefined;
|
|
93
|
+
TRIGGER_HEARTBEAT_INTERVAL_SECONDS?: number | undefined;
|
|
94
|
+
TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS?: number | undefined;
|
|
95
|
+
TRIGGER_SUCCESS_EXIT_CODE?: number | undefined;
|
|
96
|
+
TRIGGER_FAILURE_EXIT_CODE?: number | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
type Env = z.infer<typeof Env>;
|
|
99
|
+
export declare class RunnerEnv {
|
|
100
|
+
private env;
|
|
101
|
+
readonly initial: Env;
|
|
102
|
+
constructor(env: EnvObject);
|
|
103
|
+
get raw(): {
|
|
104
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: string;
|
|
105
|
+
NODE_ENV: string;
|
|
106
|
+
TRIGGER_DEPLOYMENT_VERSION: string;
|
|
107
|
+
TRIGGER_PROJECT_REF: string;
|
|
108
|
+
TRIGGER_DEPLOYMENT_ID: string;
|
|
109
|
+
TRIGGER_CONTENT_HASH: string;
|
|
110
|
+
TRIGGER_PROJECT_ID: string;
|
|
111
|
+
TRIGGER_WORKLOAD_CONTROLLER_ID: string;
|
|
112
|
+
TRIGGER_ENV_ID: string;
|
|
113
|
+
TRIGGER_WARM_START_CONNECTION_TIMEOUT_MS: number;
|
|
114
|
+
TRIGGER_WARM_START_KEEPALIVE_MS: number;
|
|
115
|
+
TRIGGER_MACHINE_CPU: string;
|
|
116
|
+
TRIGGER_MACHINE_MEMORY: string;
|
|
117
|
+
TRIGGER_RUNNER_ID: string;
|
|
118
|
+
TRIGGER_PRE_SUSPEND_WAIT_MS: number;
|
|
119
|
+
TRIGGER_POD_SCHEDULED_AT_MS: Date;
|
|
120
|
+
TRIGGER_DEQUEUED_AT_MS: Date;
|
|
121
|
+
TRIGGER_SUPERVISOR_API_PROTOCOL: "http" | "https";
|
|
122
|
+
TRIGGER_SUPERVISOR_API_DOMAIN: string;
|
|
123
|
+
TRIGGER_SUPERVISOR_API_PORT: number;
|
|
124
|
+
TRIGGER_WORKER_INSTANCE_NAME: string;
|
|
125
|
+
TRIGGER_HEARTBEAT_INTERVAL_SECONDS: number;
|
|
126
|
+
TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS: number;
|
|
127
|
+
TRIGGER_SUCCESS_EXIT_CODE: number;
|
|
128
|
+
TRIGGER_FAILURE_EXIT_CODE: number;
|
|
129
|
+
NODE_EXTRA_CA_CERTS?: string | undefined;
|
|
130
|
+
TRIGGER_RUN_ID?: string | undefined;
|
|
131
|
+
TRIGGER_SNAPSHOT_ID?: string | undefined;
|
|
132
|
+
TRIGGER_WARM_START_URL?: string | undefined;
|
|
133
|
+
TRIGGER_METADATA_URL?: string | undefined;
|
|
134
|
+
};
|
|
135
|
+
get NODE_ENV(): string;
|
|
136
|
+
get NODE_EXTRA_CA_CERTS(): string | undefined;
|
|
137
|
+
get OTEL_EXPORTER_OTLP_ENDPOINT(): string;
|
|
138
|
+
get TRIGGER_CONTENT_HASH(): string;
|
|
139
|
+
get TRIGGER_DEPLOYMENT_ID(): string;
|
|
140
|
+
get TRIGGER_DEPLOYMENT_VERSION(): string;
|
|
141
|
+
get TRIGGER_PROJECT_ID(): string;
|
|
142
|
+
get TRIGGER_PROJECT_REF(): string;
|
|
143
|
+
get TRIGGER_WORKLOAD_CONTROLLER_ID(): string;
|
|
144
|
+
get TRIGGER_ENV_ID(): string;
|
|
145
|
+
get TRIGGER_RUN_ID(): string | undefined;
|
|
146
|
+
get TRIGGER_SNAPSHOT_ID(): string | undefined;
|
|
147
|
+
get TRIGGER_WARM_START_URL(): string | undefined;
|
|
148
|
+
get TRIGGER_WARM_START_CONNECTION_TIMEOUT_MS(): number;
|
|
149
|
+
get TRIGGER_WARM_START_KEEPALIVE_MS(): number;
|
|
150
|
+
get TRIGGER_MACHINE_CPU(): string;
|
|
151
|
+
get TRIGGER_MACHINE_MEMORY(): string;
|
|
152
|
+
get TRIGGER_METADATA_URL(): string | undefined;
|
|
153
|
+
get TRIGGER_PRE_SUSPEND_WAIT_MS(): number;
|
|
154
|
+
get TRIGGER_POD_SCHEDULED_AT_MS(): Date;
|
|
155
|
+
get TRIGGER_DEQUEUED_AT_MS(): Date;
|
|
156
|
+
get TRIGGER_SUCCESS_EXIT_CODE(): number;
|
|
157
|
+
get TRIGGER_FAILURE_EXIT_CODE(): number;
|
|
158
|
+
get TRIGGER_HEARTBEAT_INTERVAL_SECONDS(): number;
|
|
159
|
+
get TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS(): number;
|
|
160
|
+
get TRIGGER_WORKER_INSTANCE_NAME(): string;
|
|
161
|
+
get TRIGGER_RUNNER_ID(): string;
|
|
162
|
+
get TRIGGER_SUPERVISOR_API_PROTOCOL(): "http" | "https";
|
|
163
|
+
get TRIGGER_SUPERVISOR_API_DOMAIN(): string;
|
|
164
|
+
get TRIGGER_SUPERVISOR_API_PORT(): number;
|
|
165
|
+
get TRIGGER_SUPERVISOR_API_URL(): string;
|
|
166
|
+
/** Overrides existing env vars with new values */
|
|
167
|
+
override(overrides: Metadata): void;
|
|
168
|
+
gatherProcessEnv(): Record<string, string>;
|
|
169
|
+
}
|
|
170
|
+
export {};
|