Use less predicatable folder names

This removes the count
This commit is contained in:
1computer1 2019-05-20 20:34:51 -04:00
parent 7a2f87da3f
commit d25e0be634
21 changed files with 44 additions and 50 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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
]);