From 920e6e705445b8862643005906c2c363c95c7905 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Mon, 22 Feb 2021 22:56:54 +1300 Subject: [PATCH] api: add rlimits to config --- api/src/config.js | 12 ++++++++++++ api/src/executor/job.js | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/src/config.js b/api/src/config.js index e541ce9..ffe6391 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -107,6 +107,18 @@ const options = [ desc: 'Max size of each stdio buffer', default: 1024, validators: [] + }, + { + key: 'max_process_count', + desc: 'Max number of processes per job', + default: 64, + validators: [] + }, + { + key: 'max_open_files', + desc: 'Max number of open files per job', + default: 2048, + validators: [] } ]; diff --git a/api/src/executor/job.js b/api/src/executor/job.js index a54bb6c..5a51a61 100644 --- a/api/src/executor/job.js +++ b/api/src/executor/job.js @@ -71,7 +71,11 @@ class Job { async safe_call(file, args, timeout){ return await new Promise((resolve, reject) => { const unshare = config.enable_unshare ? ['unshare','-n','-r'] : []; - const prlimit = ['prlimit','--nproc=64','--nofile=2048']; + const prlimit = [ + 'prlimit', + '--nproc=' + config.max_process_count, + '--nofile=' + config.max_open_files + ]; const proc_call = [ ...prlimit,