diff --git a/docker/bash/run.sh b/docker/bash/run.sh index 1800c0b..04d1373 100644 --- a/docker/bash/run.sh +++ b/docker/bash/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.sh bash program.sh -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/c/run.sh b/docker/c/run.sh index 320a72e..c637618 100644 --- a/docker/c/run.sh +++ b/docker/c/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.c gcc program.c -o program && ./program -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/clojure/run.sh b/docker/clojure/run.sh index 50d637e..8b31b02 100644 --- a/docker/clojure/run.sh +++ b/docker/clojure/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.clj clojure program.clj -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/cpp/run.sh b/docker/cpp/run.sh index afc410f..d3c8b2a 100644 --- a/docker/cpp/run.sh +++ b/docker/cpp/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.cpp g++ program.cpp -o program && ./program -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/csharp/run.sh b/docker/csharp/run.sh index 8afc09a..9028e92 100644 --- a/docker/csharp/run.sh +++ b/docker/csharp/run.sh @@ -1,10 +1,10 @@ if [ "$EVAL_EXPR" = "true" ]; then csharp -e "$1" else - mkdir "$COUNT" && cd "$COUNT" + mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.cs csc program.cs >/dev/null && mono program.exe - cd .. && rm -rf "$COUNT" + cd .. && rm -rf "$CODEDIR" fi diff --git a/docker/elixir/run.sh b/docker/elixir/run.sh index d7e3dff..d0955a9 100644 --- a/docker/elixir/run.sh +++ b/docker/elixir/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.exs elixir program.exs -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/fsharp/run.sh b/docker/fsharp/run.sh index 105eab7..2197e3f 100644 --- a/docker/fsharp/run.sh +++ b/docker/fsharp/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.fs fsharpc --optimize- program.fs >/dev/null && mono program.exe -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/go/run.sh b/docker/go/run.sh index 181b05f..7226cc5 100644 --- a/docker/go/run.sh +++ b/docker/go/run.sh @@ -1,7 +1,7 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" -export GOCACHE=/tmp/"$COUNT"/cache +export GOCACHE=/tmp/"$CODEDIR"/cache echo "$1" > program.go go run program.go -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/haskell/run.sh b/docker/haskell/run.sh index c507413..ec7767a 100644 --- a/docker/haskell/run.sh +++ b/docker/haskell/run.sh @@ -1,10 +1,10 @@ if [ "$EVAL_EXPR" = "true" ]; then ghc -e "$1" else - mkdir "$COUNT" && cd "$COUNT" + mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.hs ghc -e main program.hs - cd .. && rm -rf "$COUNT" + cd .. && rm -rf "$CODEDIR" fi diff --git a/docker/java/run.sh b/docker/java/run.sh index 15f4f16..aba2315 100644 --- a/docker/java/run.sh +++ b/docker/java/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > Main.java javac Main.java && java Main -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/lua/run.sh b/docker/lua/run.sh index b3e9ea0..1d0a47b 100644 --- a/docker/lua/run.sh +++ b/docker/lua/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.lua lua5.3 program.lua -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/ocaml/run.sh b/docker/ocaml/run.sh index 4e81749..be3a813 100644 --- a/docker/ocaml/run.sh +++ b/docker/ocaml/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.ml ocamlopt -cclib --static -o program program.ml && ./program -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/pascal/run.sh b/docker/pascal/run.sh index 06f7765..0e5965c 100644 --- a/docker/pascal/run.sh +++ b/docker/pascal/run.sh @@ -1,4 +1,4 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.pas @@ -12,4 +12,4 @@ else exit 1 fi -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/perl/run.sh b/docker/perl/run.sh index a071311..a620ee0 100644 --- a/docker/perl/run.sh +++ b/docker/perl/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.pl perl program.pl -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/prolog/run.sh b/docker/prolog/run.sh index e3786cb..9db671e 100644 --- a/docker/prolog/run.sh +++ b/docker/prolog/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.pl swipl --quiet program.pl -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/python2/run.sh b/docker/python2/run.sh index c67d836..a45fd07 100644 --- a/docker/python2/run.sh +++ b/docker/python2/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.py python program.py -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/python3/run.sh b/docker/python3/run.sh index c67d836..a45fd07 100644 --- a/docker/python3/run.sh +++ b/docker/python3/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.py python program.py -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/racket/run.sh b/docker/racket/run.sh index 91f9992..9f394b4 100644 --- a/docker/racket/run.sh +++ b/docker/racket/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.rkt racket program.rkt -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/ruby/run.sh b/docker/ruby/run.sh index ebf6738..bf8cbcd 100644 --- a/docker/ruby/run.sh +++ b/docker/ruby/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.rb ruby program.rb -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/docker/rust/run.sh b/docker/rust/run.sh index f659f53..15bce66 100644 --- a/docker/rust/run.sh +++ b/docker/rust/run.sh @@ -1,6 +1,6 @@ -mkdir "$COUNT" && cd "$COUNT" +mkdir "$CODEDIR" && cd "$CODEDIR" echo "$1" > program.rs rustc -C opt-level=0 --color never program.rs && ./program -cd .. && rm -rf "$COUNT" +cd .. && rm -rf "$CODEDIR" diff --git a/src/struct/LanguageHandler.js b/src/struct/LanguageHandler.js index 5d5aba4..6ab983c 100644 --- a/src/struct/LanguageHandler.js +++ b/src/struct/LanguageHandler.js @@ -102,7 +102,7 @@ class LanguageHandler extends AkairoHandler { try { await this.handleSpawn(proc); - this.containers.set(dockerID, { name, count: 0 }); + this.containers.set(dockerID, { name }); // eslint-disable-next-line no-console console.log(`Started container ${name} for 1computer1/comp_iler:${dockerID}.`); return this.containers.get(dockerID); @@ -111,20 +111,14 @@ class LanguageHandler extends AkairoHandler { } } - incrementCount(dockerID) { - this.containers.get(dockerID).count += 1; - } - evalCode({ language, code, options }) { const { id: dockerID = language.id, env = {} } = language.runWith(options); const queue = this.queues.get(dockerID); return queue.enqueue(async () => { - const { name, count } = await this.setupContainer(dockerID); - this.incrementCount(dockerID); - + const { name } = await this.setupContainer(dockerID); const proc = childProcess.spawn('docker', [ 'exec', - `-eCOUNT=${count}`, + `-eCODEDIR=${Date.now()}`, ...Object.entries(env).map(([k, v]) => `-e${k}=${v}`), name, '/bin/sh', '/var/run/run.sh', code ]);