MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / spawnOpenOwnedChild

Function spawnOpenOwnedChild

apps/local/src/db/owned-database.test.ts:345–387  ·  view source on GitHub ↗
(input: {
  readonly dataDir: string;
  readonly tenantId: string;
  readonly pauseAt: string;
  readonly pauseFile: string;
})

Source from the content-addressed store, hash-verified

343}
344
345const spawnOpenOwnedChild = (input: {
346 readonly dataDir: string;
347 readonly tenantId: string;
348 readonly pauseAt: string;
349 readonly pauseFile: string;
350}): OwnedChild => {
351 const code = `
352 import { collectTables } from "@executor-js/api/server";
353 import { openOwnedLocalDatabase } from "./src/db/owned-database.ts";
354 const owned = await openOwnedLocalDatabase({
355 dataDir: process.env.EXECUTOR_TEST_DATA_DIR,
356 tables: collectTables(),
357 namespace: "executor_local",
358 tenantId: process.env.EXECUTOR_TEST_TENANT,
359 });
360 console.log("OPENED");
361 await owned.close();
362 `;
363 const child = spawn(process.execPath, ["-e", code], {
364 cwd: appRoot,
365 env: {
366 ...process.env,
367 NODE_ENV: "test",
368 EXECUTOR_TEST_DATA_DIR: input.dataDir,
369 EXECUTOR_TEST_TENANT: input.tenantId,
370 EXECUTOR_V1_V2_MIGRATION_PAUSE_AT: input.pauseAt,
371 EXECUTOR_V1_V2_MIGRATION_PAUSE_FILE: input.pauseFile,
372 },
373 stdio: "pipe",
374 });
375 child.unref();
376
377 const owned: OwnedChild = { child, stdout: "", stderr: "" };
378 child.stdout.setEncoding("utf-8");
379 child.stderr.setEncoding("utf-8");
380 child.stdout.on("data", (chunk: string) => {
381 owned.stdout += chunk;
382 });
383 child.stderr.on("data", (chunk: string) => {
384 owned.stderr += chunk;
385 });
386 return owned;
387};
388
389const waitForMarker = async (
390 markerPath: string,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected