MCPcopy Create free account
hub / github.com/0PandaDEV/Ziit / createWorkerThread

Method createWorkerThread

server/utils/import-queue.ts:226–248  ·  view source on GitHub ↗
(workerId: number)

Source from the content-addressed store, hash-verified

224 }
225
226 private createWorkerThread(workerId: number): void {
227 const worker = new Worker(__filename, {
228 workerData: { workerId, isWorkerThread: true },
229 });
230
231 worker.on("message", (message) => {
232 this.handleWorkerMessage(workerId, message);
233 });
234
235 worker.on("error", (error) => {
236 handleLog(`Worker thread ${workerId} error: ${(error as Error).message}`);
237 this.restartWorkerThread(workerId);
238 });
239
240 worker.on("exit", (code) => {
241 if (code !== 0) {
242 handleLog(`Worker thread ${workerId} exited with code ${code}`);
243 this.restartWorkerThread(workerId);
244 }
245 });
246
247 this.workerThreads.set(workerId, worker);
248 }
249
250 private restartWorkerThread(workerId: number): void {
251 const oldWorker = this.workerThreads.get(workerId);

Callers 1

restartWorkerThreadMethod · 0.95

Calls 3

handleWorkerMessageMethod · 0.95
restartWorkerThreadMethod · 0.95
handleLogFunction · 0.90

Tested by

no test coverage detected