diff --git a/api/main.go b/api/main.go index b73979e..589288d 100644 --- a/api/main.go +++ b/api/main.go @@ -25,8 +25,9 @@ type problem struct { } type outbound struct { - Ran bool `json:"ran"` - Output string `json:"output"` + Generator string `json:"instance"` + Ran bool `json:"ran"` + Output string `json:"output"` } var instance int @@ -124,6 +125,7 @@ func launch(request inbound, res http.ResponseWriter) { // prepare response outbound := outbound{ + Generator: fmt.Sprintf("docker-%d", instance), Ran: err == nil, Output: strings.TrimSpace(stdout.String()), } diff --git a/docker/executors/c b/docker/executors/c index 9678d29..d4467bf 100755 --- a/docker/executors/c +++ b/docker/executors/c @@ -1,2 +1,2 @@ timeout -s KILL 10 gcc -o binary -x c $1 -timeout -s KILL 3 cat /*.args | xargs -d '\n' ./binary +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' ./binary" diff --git a/docker/executors/cpp b/docker/executors/cpp index e639f77..fd3ed82 100755 --- a/docker/executors/cpp +++ b/docker/executors/cpp @@ -1,2 +1,2 @@ timeout -s KILL 10 g++ -o binary -x c++ $1 -timeout -s KILL 3 cat /*.args | xargs -d '\n' ./binary +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' ./binary" diff --git a/docker/executors/csharp b/docker/executors/csharp index 6f43b92..410cd60 100755 --- a/docker/executors/csharp +++ b/docker/executors/csharp @@ -1,3 +1,3 @@ cp /*.code . timeout -s KILL 10 mcs $(echo $1 | sed 's/\///') -out:binary -timeout -s KILL 3 cat /*.args | xargs -d '\n' mono binary +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' mono binary" diff --git a/docker/executors/go b/docker/executors/go index 822cdad..bcc2d40 100755 --- a/docker/executors/go +++ b/docker/executors/go @@ -2,4 +2,4 @@ cp /*.code interim.go file="interim.go" timeout -s KILL 10 go build $file file=${file%%.*} -timeout -s KILL 3 cat /*.args | xargs -d '\n' ./$file +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' ./$file" diff --git a/docker/executors/java b/docker/executors/java index d210f56..fe30da1 100755 --- a/docker/executors/java +++ b/docker/executors/java @@ -2,4 +2,4 @@ cp /*.code interim.java name=$(cat interim.java | grep -Eo 'public\s+class\s+([A-Za-z0-9]+)' | sed -n 's/ */ /gp' | cut -d' ' -f3) mv interim.java $name.java timeout -s KILL 10 javac $name.java -timeout -s KILL 3 cat /*.args | xargs -d '\n' java $name +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' java $name" diff --git a/docker/executors/nasm b/docker/executors/nasm index 45c8bc5..bbd0923 100755 --- a/docker/executors/nasm +++ b/docker/executors/nasm @@ -1,3 +1,3 @@ timeout -s KILL 10 nasm -f elf64 -o binary.o $1 timeout -s KILL 10 ld binary.o -o binary -timeout -s KILL 3 cat /*.args | xargs -d '\n' ./binary +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' ./binary" diff --git a/docker/executors/node b/docker/executors/node index 379297d..de37518 100755 --- a/docker/executors/node +++ b/docker/executors/node @@ -1 +1 @@ -timeout -s KILL 3 cat /*.args | xargs -d '\n' nodejs $1 +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' nodejs $1" diff --git a/docker/executors/php b/docker/executors/php index 6635ac1..6baa0ee 100755 --- a/docker/executors/php +++ b/docker/executors/php @@ -1 +1 @@ -timeout -s KILL 3 cat /*.args | xargs -d '\n' php $1 +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' php $1" diff --git a/docker/executors/python2 b/docker/executors/python2 index b8d45f3..a6ef3f2 100755 --- a/docker/executors/python2 +++ b/docker/executors/python2 @@ -1 +1 @@ -timeout -s KILL 3 cat /*.args | xargs -d '\n' python2 $1 +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' python2 $1" diff --git a/docker/executors/python3 b/docker/executors/python3 index a06a39d..13a99c6 100755 --- a/docker/executors/python3 +++ b/docker/executors/python3 @@ -1 +1 @@ -timeout -s KILL 3 cat /*.args | xargs -d '\n' python3.6 $1 +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' python3.6 $1" diff --git a/docker/executors/r b/docker/executors/r index 3d33f79..1941193 100755 --- a/docker/executors/r +++ b/docker/executors/r @@ -1 +1 @@ -timeout -s KILL 3 cat /*.args | xargs -d '\n' Rscript $1 +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' Rscript $1" diff --git a/docker/executors/ruby b/docker/executors/ruby index 14f4fa0..f058a29 100755 --- a/docker/executors/ruby +++ b/docker/executors/ruby @@ -1 +1 @@ -timeout -s KILL 3 cat /*.args | xargs -d '\n' ruby $1 +timeout -s KILL 3 bash -c "cat /*.args | xargs -d '\n' ruby $1" diff --git a/var/notes.txt b/var/notes.txt index 8a456c2..c2e4705 100644 --- a/var/notes.txt +++ b/var/notes.txt @@ -1,9 +1,25 @@ create vm git piston + install dock and piston units systemctl enable dock@{1..10}.service systemctl start dock@{1..10}.service systemctl enable piston@{1..10}.service systemctl start piston@{1..10}.service + install nginx config -cp /var/lib/docker -> docker-1, ..., docker-10 + +export image: +./multidock 1 save -o piston.tar piston:latest + +copy in image: +./multidock 1 load -i piston.tar +./multidock 2 load -i piston.tar +./multidock 3 load -i piston.tar +./multidock 4 load -i piston.tar +./multidock 5 load -i piston.tar +./multidock 6 load -i piston.tar +./multidock 7 load -i piston.tar +./multidock 8 load -i piston.tar +./multidock 9 load -i piston.tar +./multidock 10 load -i piston.tar diff --git a/var/piston.nginx b/var/piston.nginx index 5990602..d20052c 100644 --- a/var/piston.nginx +++ b/var/piston.nginx @@ -12,9 +12,10 @@ upstream piston { } server { - listen 80; + listen 1337; location / { + proxy_buffering off; proxy_pass http://piston; } } diff --git a/var/start_piston b/var/start_piston new file mode 100755 index 0000000..7cc6559 --- /dev/null +++ b/var/start_piston @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +systemctl start piston@1.service +systemctl start piston@2.service +systemctl start piston@3.service +systemctl start piston@4.service +systemctl start piston@5.service +systemctl start piston@6.service +systemctl start piston@7.service +systemctl start piston@8.service +systemctl start piston@9.service +systemctl start piston@10.service +systemctl start dock@1.service +systemctl start dock@2.service +systemctl start dock@3.service +systemctl start dock@4.service +systemctl start dock@5.service +systemctl start dock@6.service +systemctl start dock@7.service +systemctl start dock@8.service +systemctl start dock@9.service +systemctl start dock@10.service diff --git a/var/stop_piston b/var/stop_piston new file mode 100755 index 0000000..a32c740 --- /dev/null +++ b/var/stop_piston @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +systemctl stop piston@{1..10}.service +systemctl stop dock@{1..10}.service