INNER CODE UNIT · TypeScript

detachedStartEnvironment

lidge-jun/opencodex · src/cli/index.ts:808

function detachedStartEnvironment(): NodeJS.ProcessEnv {
  const env: NodeJS.ProcessEnv = withoutSiblingMarker(process.env);
  // Only a real service wrapper may claim supervision. A detached ensure/tray child is an
  // ordinary owner, never a sibling: while live it maintains routing, and on exit restores it.
  // The supervisor markers ride along whenever this runs inside a service child's
  // environment, so they must leave with OCX_SERVICE — otherwise the child would
  // answer the ownership gate as a managed job it is not.
  delete env.OCX_SERVICE;
  delete env[SERVICE_MANAGED_ENV];
  delete env[WINDOWS_WRAPPER_PROTOCOL_ENV];
  return withProcessRuntimeProvenance(env);
}

async function handleEnsure(options: { existingIsSuccess?: boolean; forceStart?: boolean; onSpawn?: (child: ReturnType<typeof spawn>) => void } = {}): Promise<boolean> {
  const owner = await findProxyOwnerBeforeJournalRecovery({ probeConfiguredPort: true, deferPidCleanup: true });
  if (!owner.live) await recoverStartStateUnderOwnershipLease({
    supervised: false,
    acquireLease: () => acquireOwnershipMutationLease(serviceStatePaths()),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…