updated commands

This commit is contained in:
Brian Seymour 2018-10-08 15:53:03 -05:00
parent f6f6eaf502
commit 8dcfea4b90
17 changed files with 61 additions and 16 deletions

View File

@ -25,8 +25,9 @@ type problem struct {
} }
type outbound struct { type outbound struct {
Ran bool `json:"ran"` Generator string `json:"instance"`
Output string `json:"output"` Ran bool `json:"ran"`
Output string `json:"output"`
} }
var instance int var instance int
@ -124,6 +125,7 @@ func launch(request inbound, res http.ResponseWriter) {
// prepare response // prepare response
outbound := outbound{ outbound := outbound{
Generator: fmt.Sprintf("docker-%d", instance),
Ran: err == nil, Ran: err == nil,
Output: strings.TrimSpace(stdout.String()), Output: strings.TrimSpace(stdout.String()),
} }

View File

@ -1,2 +1,2 @@
timeout -s KILL 10 gcc -o binary -x c $1 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"

View File

@ -1,2 +1,2 @@
timeout -s KILL 10 g++ -o binary -x c++ $1 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"

View File

@ -1,3 +1,3 @@
cp /*.code . cp /*.code .
timeout -s KILL 10 mcs $(echo $1 | sed 's/\///') -out:binary 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"

View File

@ -2,4 +2,4 @@ cp /*.code interim.go
file="interim.go" file="interim.go"
timeout -s KILL 10 go build $file timeout -s KILL 10 go build $file
file=${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"

View File

@ -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) 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 mv interim.java $name.java
timeout -s KILL 10 javac $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"

View File

@ -1,3 +1,3 @@
timeout -s KILL 10 nasm -f elf64 -o binary.o $1 timeout -s KILL 10 nasm -f elf64 -o binary.o $1
timeout -s KILL 10 ld binary.o -o binary 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"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,25 @@
create vm create vm
git piston git piston
install dock and piston units install dock and piston units
systemctl enable dock@{1..10}.service systemctl enable dock@{1..10}.service
systemctl start dock@{1..10}.service systemctl start dock@{1..10}.service
systemctl enable piston@{1..10}.service systemctl enable piston@{1..10}.service
systemctl start piston@{1..10}.service systemctl start piston@{1..10}.service
install nginx config 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

View File

@ -12,9 +12,10 @@ upstream piston {
} }
server { server {
listen 80; listen 1337;
location / { location / {
proxy_buffering off;
proxy_pass http://piston; proxy_pass http://piston;
} }
} }

22
var/start_piston Executable file
View File

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

4
var/stop_piston Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
systemctl stop piston@{1..10}.service
systemctl stop dock@{1..10}.service