From 03a241086e06967a097bd3da880fcb22916c762f Mon Sep 17 00:00:00 2001 From: 1computer1 Date: Wed, 13 Mar 2019 02:48:48 -0400 Subject: [PATCH] Add more configurations --- config.example.json | 5 ++++- src/struct/LanguageHandler.js | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.example.json b/config.example.json index fb13dea..8000163 100644 --- a/config.example.json +++ b/config.example.json @@ -6,5 +6,8 @@ "haskell", "python", "Leave empty to enable all languages" - ] + ], + "memory": "128m", + "cpus": "0.5", + "timeout": 10000 } diff --git a/src/struct/LanguageHandler.js b/src/struct/LanguageHandler.js index 3f00fef..f6e948c 100644 --- a/src/struct/LanguageHandler.js +++ b/src/struct/LanguageHandler.js @@ -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 => {