Add more configurations

This commit is contained in:
1computer1 2019-03-13 02:48:48 -04:00
parent 39edb5b29a
commit 03a241086e
2 changed files with 7 additions and 4 deletions

View file

@ -6,5 +6,8 @@
"haskell",
"python",
"Leave empty to enable all languages"
]
],
"memory": "128m",
"cpus": "0.5",
"timeout": 10000
}

View file

@ -65,7 +65,7 @@ class LanguageHandler extends AkairoHandler {
const { id, env } = language.runWith(options);
const proc = childProcess.spawn('docker', [
'run', '--rm', `--name=${name}`,
'--net=none', '--cpus=0.5', '-m=256m',
'--net=none', `--cpus=${this.client.config.cpus}`, `-m=${this.client.config.memory}`,
...Object.entries(env).map(([k, v]) => `-e${k}=${v}`),
`1computer1/comp_iler:${id}`,
'/bin/sh', '/var/run/run.sh', code
@ -79,11 +79,11 @@ class LanguageHandler extends AkairoHandler {
childProcess.execSync(`docker kill --signal=9 ${name} >/dev/null 2>/dev/null`);
}
reject(new Error('Evaluation timed out'));
reject(new Error('Timed out'));
} catch (e) {
reject(e);
}
}, 10000);
}, this.client.config.timeout);
let data = '';
proc.stdout.on('data', chunk => {