MCPcopy
hub / github.com/triggerdotdev/trigger.dev / DockerTaskOperations

Class DockerTaskOperations

apps/docker-provider/src/index.ts:35–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35class DockerTaskOperations implements TaskOperations {
36 #initialized = false;
37 #canCheckpoint = false;
38
39 constructor(private opts = { forceSimulate: false }) {}
40
41 async #initialize(): Promise<InitializeReturn> {
42 if (this.#initialized) {
43 return this.#getInitializeReturn();
44 }
45
46 logger.log("Initializing task operations");
47
48 if (this.opts.forceSimulate) {
49 logger.log("Forced simulation enabled. Will simulate regardless of checkpoint support.");
50 }
51
52 try {
53 await $`criu --version`;
54 } catch (error) {
55 logger.error("No checkpoint support: Missing CRIU binary. Will simulate instead.");
56 this.#canCheckpoint = false;
57 this.#initialized = true;
58
59 return this.#getInitializeReturn();
60 }
61
62 try {
63 await $`docker checkpoint`;
64 } catch (error) {
65 logger.error("No checkpoint support: Docker needs to have experimental features enabled");
66 logger.error("Will simulate instead");
67 this.#canCheckpoint = false;
68 this.#initialized = true;
69
70 return this.#getInitializeReturn();
71 }
72
73 logger.log("Full checkpoint support!");
74
75 this.#initialized = true;
76 this.#canCheckpoint = true;
77
78 return this.#getInitializeReturn();
79 }
80
81 #getInitializeReturn(): InitializeReturn {
82 return {
83 canCheckpoint: this.#canCheckpoint,
84 willSimulate: !this.#canCheckpoint || this.opts.forceSimulate,
85 };
86 }
87
88 async index(opts: TaskOperationsIndexOptions) {
89 await this.#initialize();
90
91 const containerName = this.#getIndexContainerName(opts.shortCode);
92

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…