diff --git a/api/main.go b/api/main.go index 51741d6..562bc50 100644 --- a/api/main.go +++ b/api/main.go @@ -70,6 +70,7 @@ func Execute(res http.ResponseWriter, req *http.Request) { "brainfuck", "bf", "c", "cpp", "c++", + "crystal", "cr", "csharp", "cs", "c#", "deno", "denojs", "denots", "elixir", "exs", @@ -150,6 +151,8 @@ func launch(request Inbound, res http.ResponseWriter) { execlang = "brainfuck" case "c++": execlang = "cpp" + case "cr": + execlang = "crystal" case "cs", "c#": execlang = "csharp" case "denojs", "denots": diff --git a/lxc/execute b/lxc/execute index 45a7f46..31a4bd8 100755 --- a/lxc/execute +++ b/lxc/execute @@ -57,6 +57,9 @@ case "$lang" in "cpp" | "c++") bin=cpp ;; +"crystal" | "cr") + bin=crystal + ;; "csharp" | "cs" | "c#") bin=csharp ;; diff --git a/lxc/executors/crystal b/lxc/executors/crystal new file mode 100644 index 0000000..ba5b348 --- /dev/null +++ b/lxc/executors/crystal @@ -0,0 +1,3 @@ +cd /tmp/$2 +timeout -s KILL 10 crystal build code.code +runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ./code" diff --git a/lxc/test_all_lxc b/lxc/test_all_lxc index 8e7130c..09bf3cd 100755 --- a/lxc/test_all_lxc +++ b/lxc/test_all_lxc @@ -7,6 +7,8 @@ echo 'testing c' ../execute c test.c echo 'testing cpp' ../execute cpp test.cpp +echo 'testing crystal' +../execute crystal test.cr echo 'testing cs' ../execute cs test.cs echo 'testing deno ts' diff --git a/lxc/tests/test.cr b/lxc/tests/test.cr new file mode 100644 index 0000000..869b723 --- /dev/null +++ b/lxc/tests/test.cr @@ -0,0 +1 @@ +puts "good" \ No newline at end of file diff --git a/lxc/versions b/lxc/versions index 12b5f76..9579032 100755 --- a/lxc/versions +++ b/lxc/versions @@ -21,6 +21,10 @@ echo 'cpp' lxc-attach --clear-env -n piston -- /bin/bash -l -c "g++ -v" echo '---' +echo 'crystal' +lxc-attach --clear-env -n piston -- /bin/bash -l -c "crystal -v" +echo '---' + echo 'csharp' lxc-attach --clear-env -n piston -- /bin/bash -l -c "mcs --version" echo '---' diff --git a/readme.md b/readme.md index a7ccaff..0bd729d 100644 --- a/readme.md +++ b/readme.md @@ -261,6 +261,15 @@ cd nim-1.4.0 echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile source /opt/.profile +# install crystal +# final binary: /opt/crystal/crystal-0.35.1-1/bin/crystal +# get version: /opt/crystal/crystal-0.35.1-1/bin/crystal -v +cd /opt && mkdir crystal && cd crystal +wget https://github.com/crystal-lang/crystal/releases/download/0.35.1/crystal-0.35.1-1-linux-x86_64.tar.gz +tar -xzf crystal-0.35.1-1-linux-x86_64.tar.gz +echo 'export PATH="$PATH:/opt/crystal/crystal-0.35.1-1/bin:$PATH"' >> /opt/.profile +source /opt/.profile + # create runnable users and apply limits for i in {1..150}; do useradd -M runner$i @@ -362,6 +371,7 @@ If an invalid language is supplied, a typical response will look like the follow - bash - c - cpp +- crystal - csharp - deno - elixir