api: add rlimits to config

This commit is contained in:
Thomas Hobson 2021-02-22 22:56:54 +13:00
parent e31e66aad5
commit 920e6e7054
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
2 changed files with 17 additions and 1 deletions

View File

@ -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: []
}
];

View File

@ -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,