70 lines
1.3 KiB
Bash
Executable File
70 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
#docker run --rm -it piston /usr/bin/python -V
|
|
#docker run --rm -it piston /usr/bin/python3 -V
|
|
#docker run --rm -it piston /usr/bin/ruby --version
|
|
#docker run --rm -it piston /usr/bin/nodejs --version
|
|
|
|
dir="$( cd "$( dirname "$0" )" && pwd )"
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "invalid args"
|
|
exit
|
|
fi
|
|
if [ -z "$2" ]; then
|
|
echo "invalid args"
|
|
exit
|
|
fi
|
|
|
|
lang=$1
|
|
abs=$2
|
|
file=$(basename $abs)
|
|
|
|
bin=
|
|
case "$lang" in
|
|
"python2")
|
|
bin=executor_python2
|
|
;;
|
|
"python" | "python3")
|
|
bin=executor_python3
|
|
;;
|
|
"ruby")
|
|
bin=executor_ruby
|
|
;;
|
|
"javascript" | "js" | "node")
|
|
bin=executor_node
|
|
;;
|
|
"c")
|
|
bin=executor_c
|
|
;;
|
|
"cpp" | "c++")
|
|
bin=executor_cpp
|
|
;;
|
|
"go")
|
|
bin=executor_go
|
|
;;
|
|
*)
|
|
echo "invalid language"
|
|
exit
|
|
esac
|
|
|
|
docker run \
|
|
-m 64m \
|
|
--network none \
|
|
--cpus=".5" \
|
|
--ulimit nproc=8:8 \
|
|
--kernel-memory 6m \
|
|
--rm \
|
|
-v $abs:/$file:ro \
|
|
-v $dir/executors/python2:/executor_python2:ro \
|
|
-v $dir/executors/python3:/executor_python3:ro \
|
|
-v $dir/executors/ruby:/executor_ruby:ro \
|
|
-v $dir/executors/node:/executor_node:ro \
|
|
-v $dir/executors/c:/executor_c:ro \
|
|
-v $dir/executors/cpp:/executor_cpp:ro \
|
|
-v $dir/executors/go:/executor_go:ro \
|
|
piston \
|
|
timeout -s HUP 15 /$bin /$file $file 2>&1
|
|
|
|
rm -f /tmp/$file
|