judge: 支持调整stdio缓冲区大小

This commit is contained in:
undefined committed 2021-02-04 23:20:57 +08:00
1 parent 91f364d1b9
commit bb856bacce
9 files changed
+24 -16

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ let config = {
cache_dir: path.resolve(os.homedir(), '.cache', 'hydro', 'judge'),
tmp_dir: path.resolve(os.tmpdir(), 'hydro', 'judge'),
tmpfs_size: '256m',
stdio_size: '32m',
retry_delay_sec: 15,
sandbox_host: 'http://localhost:5050',
testcases_max: 100,
+5 -3
View File
@@ -3,7 +3,8 @@ import fs from 'fs-extra';
import { argv } from 'yargs';
import * as STATUS from './status';
import { SystemError } from './error';
import { cmd } from './utils';
import { cmd, parseMemoryMB } from './utils';
import { getConfig } from './config';
const env = ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOME=/w'];
const axios = Axios.create({ baseURL: argv.sandbox as string || 'http://localhost:5050' });
@@ -26,13 +27,14 @@ function proc({
process_limit = 32,
stdin = '', copyIn = {}, copyOut = [], copyOutCached = [],
} = {}) {
const size = parseMemoryMB(getConfig('stdio_size'));
return {
args: cmd(execute.replace(/\$\{dir\}/g, '/w')),
env,
files: [
stdin ? { src: stdin } : { content: '' },
{ name: 'stdout', max: 1024 * 1024 * 32 },
{ name: 'stderr', max: 1024 * 1024 * 32 },
{ name: 'stdout', max: 1024 * 1024 * size },
{ name: 'stderr', max: 1024 * 1024 * size },
],
cpuLimit: time_limit_ms * 1000 * 1000,
realCpuLimit: time_limit_ms * 3000 * 1000,