MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / initialize

Method initialize

apps/coordinator/src/index.ts:128–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 constructor(private opts = { forceSimulate: false }) {}
127
128 async initialize(): Promise<CheckpointerInitializeReturn> {
129 if (this.#initialized) {
130 return this.#getInitializeReturn();
131 }
132
133 this.#logger.log(`${this.#dockerMode ? "Docker" : "Kubernetes"} mode`);
134
135 if (this.#dockerMode) {
136 try {
137 await $`criu --version`;
138 } catch (error) {
139 this.#logger.error("No checkpoint support: Missing CRIU binary");
140 this.#logger.error("Will simulate instead");
141 this.#canCheckpoint = false;
142 this.#initialized = true;
143
144 return this.#getInitializeReturn();
145 }
146
147 try {
148 await $`docker checkpoint`;
149 } catch (error) {
150 this.#logger.error(
151 "No checkpoint support: Docker needs to have experimental features enabled"
152 );
153 this.#logger.error("Will simulate instead");
154 this.#canCheckpoint = false;
155 this.#initialized = true;
156
157 return this.#getInitializeReturn();
158 }
159 } else {
160 try {
161 await $`buildah login --get-login ${REGISTRY_HOST}`;
162 } catch (error) {
163 this.#logger.error(`No checkpoint support: Not logged in to registry ${REGISTRY_HOST}`);
164 this.#canCheckpoint = false;
165 this.#initialized = true;
166
167 return this.#getInitializeReturn();
168 }
169 }
170
171 this.#logger.log(
172 `Full checkpoint support${
173 this.#dockerMode && this.opts.forceSimulate ? " with forced simulation enabled." : "!"
174 }`
175 );
176
177 this.#initialized = true;
178 this.#canCheckpoint = true;
179
180 return this.#getInitializeReturn();
181 }
182
183 #getInitializeReturn(): CheckpointerInitializeReturn {
184 return {

Callers 4

#checkpointAndPushMethod · 0.95
constructorMethod · 0.45
trigger.config.tsFile · 0.45

Calls 3

#getInitializeReturnMethod · 0.95
logMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected