UNPKG

@remotion/renderer

Version:

Render Remotion videos using Node.js or Bun

28 lines (27 loc) 1.03 kB
"use strict"; // Kubernetes uses the following command to spawn Docker containers: // docker run --cpuset-cpus="0,1" to assign only 2 CPUs. // However, Node.js returns the core count of the host system (up to 96!) Object.defineProperty(exports, "__esModule", { value: true }); exports.getCpuCount = exports.getConcurrencyFromNProc = void 0; const node_child_process_1 = require("node:child_process"); const node_os_1 = require("node:os"); // We also get it from nproc and use the minimum of the two. const getConcurrencyFromNProc = () => { try { return parseInt((0, node_child_process_1.execSync)('nproc', { stdio: 'pipe' }).toString().trim(), 10); } catch (_a) { return null; } }; exports.getConcurrencyFromNProc = getConcurrencyFromNProc; const getCpuCount = () => { const node = (0, node_os_1.cpus)().length; const nproc = (0, exports.getConcurrencyFromNProc)(); if (nproc === null) { return node; } return Math.min(nproc, node); }; exports.getCpuCount = getCpuCount;