|
|
@ -74,14 +74,15 @@ function proc(params: Parameter): Cmd {
|
|
|
|
const copyOut = supportOptional
|
|
|
|
const copyOut = supportOptional
|
|
|
|
? params.copyOut
|
|
|
|
? params.copyOut
|
|
|
|
: (params.copyOut || []).map((i) => (i.endsWith('?') ? i.substring(0, i.length - 1) : i));
|
|
|
|
: (params.copyOut || []).map((i) => (i.endsWith('?') ? i.substring(0, i.length - 1) : i));
|
|
|
|
const size = params.stdioLimit || params.cacheStdoutAndStderr ? parseMemoryMB(getConfig('stdio_size')) : 4;
|
|
|
|
const stdioLimit = parseMemoryMB(getConfig('stdio_size'));
|
|
|
|
const rate = getConfig('rate');
|
|
|
|
const stdioSize = params.stdioLimit || params.cacheStdoutAndStderr ? stdioLimit : 4;
|
|
|
|
const copyOutCached = [...(params.copyOutCached || [])];
|
|
|
|
const copyOutCached = [...(params.copyOutCached || [])];
|
|
|
|
if (params.cacheStdoutAndStderr) copyOutCached.push(params.filename ? `${params.filename}.out?` : 'stdout', 'stderr');
|
|
|
|
if (params.cacheStdoutAndStderr) copyOutCached.push(params.filename ? `${params.filename}.out?` : 'stdout', 'stderr');
|
|
|
|
const copyIn = { ...(params.copyIn || {}) };
|
|
|
|
const copyIn = { ...(params.copyIn || {}) };
|
|
|
|
const stdin = params.stdin || { content: '' };
|
|
|
|
const stdin = params.stdin || { content: '' };
|
|
|
|
if (params.filename) copyIn[`${params.filename}.in`] = stdin;
|
|
|
|
if (params.filename) copyIn[`${params.filename}.in`] = stdin;
|
|
|
|
const time = params.time || 16000;
|
|
|
|
const time = params.time || 16000;
|
|
|
|
|
|
|
|
const cpuLimit = Math.floor(time * 1000 * 1000 * getConfig('rate'));
|
|
|
|
const memory = params.memory || parseMemoryMB(getConfig('memoryMax'));
|
|
|
|
const memory = params.memory || parseMemoryMB(getConfig('memoryMax'));
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
args: parseArgs(params.execute || ''),
|
|
|
|
args: parseArgs(params.execute || ''),
|
|
|
@ -91,16 +92,16 @@ function proc(params: Parameter): Cmd {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
files: [
|
|
|
|
files: [
|
|
|
|
params.filename ? { content: '' } : stdin,
|
|
|
|
params.filename ? { content: '' } : stdin,
|
|
|
|
{ name: 'stdout', max: Math.floor(1024 * 1024 * size) },
|
|
|
|
{ name: 'stdout', max: Math.floor(1024 * 1024 * stdioSize) },
|
|
|
|
{ name: 'stderr', max: Math.floor(1024 * 1024 * size) },
|
|
|
|
{ name: 'stderr', max: Math.floor(1024 * 1024 * stdioSize) },
|
|
|
|
],
|
|
|
|
],
|
|
|
|
cpuLimit: Math.floor(time * 1000 * 1000 * rate),
|
|
|
|
cpuLimit,
|
|
|
|
clockLimit: Math.floor(time * 3000 * 1000 * rate),
|
|
|
|
clockLimit: 3 * cpuLimit,
|
|
|
|
memoryLimit: Math.floor(memory * 1024 * 1024),
|
|
|
|
memoryLimit: Math.floor(memory * 1024 * 1024),
|
|
|
|
strictMemoryLimit: getConfig('strict_memory'),
|
|
|
|
strictMemoryLimit: getConfig('strict_memory'),
|
|
|
|
// stackLimit: memory * 1024 * 1024,
|
|
|
|
// stackLimit: memory * 1024 * 1024,
|
|
|
|
procLimit: params.processLimit || getConfig('processLimit'),
|
|
|
|
procLimit: params.processLimit || getConfig('processLimit'),
|
|
|
|
copyOutMax: Math.floor(1024 * 1024 * size * 3),
|
|
|
|
copyOutMax: Math.floor(1024 * 1024 * stdioLimit * 3),
|
|
|
|
copyIn,
|
|
|
|
copyIn,
|
|
|
|
copyOut,
|
|
|
|
copyOut,
|
|
|
|
copyOutCached,
|
|
|
|
copyOutCached,
|
|
|
|