@@ -63,6 +63,8 @@ var CPP_TIMEOUT_SECS = 15; // the C/C++ backend is also SUPER SLOW :/
6363
6464var MAX_BUFFER_SIZE = 10 * 1024 * 1024 ;
6565
66+ var MEM_LIMIT = "256M" ;
67+
6668
6769// bind() res and useJSONP before using
6870function postExecHandler ( res , useJSONP , err , stdout , stderr ) {
@@ -133,7 +135,7 @@ function exec_js_handler(useJSONP /* use bind first */, isTypescript /* use bind
133135 if ( USE_DOCKER_SANDBOX ) {
134136 // this needs to match the docker setup in Dockerfile
135137 exeFile = '/usr/bin/docker' ; // absolute path to docker executable
136- args . push ( 'run' , '--rm' , '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
138+ args . push ( 'run' , '-m' , MEM_LIMIT , '- -rm', '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
137139 //'node', // built-in Node.js version
138140 '/tmp/javascript/node-v6.0.0-linux-x64/bin/node' , // custom Node.js version
139141 '--expose-debug-as=Debug' ,
@@ -193,7 +195,7 @@ function exec_java_handler(useJSONP /* use bind first */, req, res) {
193195 if ( USE_DOCKER_SANDBOX ) {
194196 // this needs to match the docker setup in Dockerfile
195197 exeFile = '/usr/bin/docker' ; // absolute path to docker executable
196- args . push ( 'run' , '--rm' , '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
198+ args . push ( 'run' , '-m' , MEM_LIMIT , '- -rm', '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
197199 '/tmp/run-java-backend.sh' ,
198200 inputObjJSON ) ;
199201 } else {
@@ -223,7 +225,7 @@ function exec_ruby_handler(useJSONP /* use bind first */, req, res) {
223225 if ( USE_DOCKER_SANDBOX ) {
224226 // this needs to match the docker setup in Dockerfile
225227 exeFile = '/usr/bin/docker' ; // absolute path to docker executable
226- args . push ( 'run' , '--rm' , '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
228+ args . push ( 'run' , '-m' , MEM_LIMIT , '- -rm', '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
227229 '/tmp/ruby/ruby' ,
228230 '/tmp/ruby/pg_logger.rb' ,
229231 '-c' ,
@@ -258,7 +260,7 @@ function exec_cpp_handler(useCPP /* use bind first */, useJSONP /* use bind firs
258260 if ( USE_DOCKER_SANDBOX ) {
259261 // this needs to match the docker setup in Dockerfile
260262 exeFile = '/usr/bin/docker' ; // absolute path to docker executable
261- args . push ( 'run' , '--rm' , '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/opt-cpp-backend:v1' ,
263+ args . push ( 'run' , '-m' , MEM_LIMIT , '- -rm', '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/opt-cpp-backend:v1' ,
262264 'python' ,
263265 '/tmp/opt-cpp-backend/run_cpp_backend.py' ,
264266 usrCod ,
@@ -295,7 +297,7 @@ function executePython(pyVer, req, res) {
295297 if ( USE_DOCKER_SANDBOX ) {
296298 // this needs to match the docker setup in Dockerfile
297299 exeFile = '/usr/bin/docker' ; // absolute path to docker executable
298- args . push ( 'run' , '--rm' , '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
300+ args . push ( 'run' , '-m' , MEM_LIMIT , '- -rm', '--user=netuser' , '--net=none' , '--cap-drop' , 'all' , 'pgbovine/cokapi:v1' ,
299301 ( pyVer == 'py2' ? 'python' : 'python3' ) ,
300302 '/tmp/python/generate_json_trace.py' ) ;
301303 } else {
0 commit comments