mirror of
https://github.com/QingdaoU/JudgeServer.git
synced 2025-11-04 14:50:01 +08:00
add javascript
This commit is contained in:
parent
6514ddf0d6
commit
9aac545910
@ -2,13 +2,16 @@ FROM ubuntu:18.04
|
|||||||
|
|
||||||
COPY build/java_policy /etc
|
COPY build/java_policy /etc
|
||||||
RUN export DEBIAN_FRONTEND=noninteractive && \
|
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||||
buildDeps='software-properties-common git libtool cmake python-dev python3-pip python-pip libseccomp-dev' && \
|
buildDeps='software-properties-common git libtool cmake python-dev python3-pip python-pip libseccomp-dev curl' && \
|
||||||
|
phpJitOption='opcache.enable=1\nopcache.enable_cli=1\nopcache.jit=1205\nopcache.jit_buffer_size=64M' && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y tzdata python python3 python-pkg-resources python3-pkg-resources gcc g++ $buildDeps && \
|
apt-get install -y tzdata python python3 python-pkg-resources python3-pkg-resources gcc g++ $buildDeps && \
|
||||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||||
dpkg-reconfigure -f noninteractive tzdata && \
|
dpkg-reconfigure -f noninteractive tzdata && \
|
||||||
add-apt-repository ppa:openjdk-r/ppa && add-apt-repository ppa:longsleep/golang-backports && add-apt-repository ppa:ondrej/php && \
|
add-apt-repository ppa:openjdk-r/ppa && add-apt-repository ppa:longsleep/golang-backports && add-apt-repository ppa:ondrej/php && \
|
||||||
apt-get update && apt-get install -y golang-go openjdk-8-jdk php-cli && \
|
curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
|
||||||
|
apt-get update && apt-get install -y golang-go openjdk-8-jdk php-cli nodejs && \
|
||||||
|
echo $phpJitOption > /etc/php/8.0/cli/conf.d/10-opcache-jit.ini && \
|
||||||
pip3 install -I --no-cache-dir psutil gunicorn flask requests idna && \
|
pip3 install -I --no-cache-dir psutil gunicorn flask requests idna && \
|
||||||
cd /tmp && git clone -b newnew --depth 1 https://github.com/QingdaoU/Judger && cd Judger && \
|
cd /tmp && git clone -b newnew --depth 1 https://github.com/QingdaoU/Judger && cd Judger && \
|
||||||
mkdir build && cd build && cmake .. && make && make install && cd ../bindings/Python && python3 setup.py install && \
|
mkdir build && cd build && cmake .. && make && make install && cd ../bindings/Python && python3 setup.py install && \
|
||||||
@ -16,7 +19,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
|
|||||||
apt-get clean && rm -rf /var/lib/apt/lists/* && \
|
apt-get clean && rm -rf /var/lib/apt/lists/* && \
|
||||||
mkdir -p /code && \
|
mkdir -p /code && \
|
||||||
useradd -u 12001 compiler && useradd -u 12002 code && useradd -u 12003 spj && usermod -a -G code spj
|
useradd -u 12001 compiler && useradd -u 12002 code && useradd -u 12003 spj && usermod -a -G code spj
|
||||||
RUN echo -e 'opcache.enable=1\nopcache.enable_cli=1\nopcache.jit=1205\nopcache.jit_buffer_size=64M' > /etc/php/8.0/cli/conf.d/10-opcache-jit.ini
|
|
||||||
HEALTHCHECK --interval=5s --retries=3 CMD python3 /code/service.py
|
HEALTHCHECK --interval=5s --retries=3 CMD python3 /code/service.py
|
||||||
ADD server /code
|
ADD server /code
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
|||||||
@ -3,8 +3,7 @@ import json
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from .languages import c_lang_config, cpp_lang_config, java_lang_config, c_lang_spj_config, \
|
from .languages import c_lang_config, cpp_lang_config, java_lang_config, c_lang_spj_config, c_lang_spj_compile, py2_lang_config, py3_lang_config, go_lang_config, php_lang_config, js_lang_config
|
||||||
c_lang_spj_compile, py2_lang_config, py3_lang_config, go_lang_config, php_lang_config
|
|
||||||
|
|
||||||
|
|
||||||
class JudgeServerClientError(Exception):
|
class JudgeServerClientError(Exception):
|
||||||
@ -121,6 +120,16 @@ func main() {
|
|||||||
fscanf(STDIN, "%d %d", $a, $b);
|
fscanf(STDIN, "%d %d", $a, $b);
|
||||||
print($a + $b);"""
|
print($a + $b);"""
|
||||||
|
|
||||||
|
js_src = """const readline = require('readline');
|
||||||
|
const rl = readline.createInterface({ input: process.stdin });
|
||||||
|
rl.on('line', (input) => {
|
||||||
|
if (input === '') {
|
||||||
|
return rl.close();
|
||||||
|
}
|
||||||
|
const [a, b] = input.split(' ').map(Number)
|
||||||
|
console.log(a + b);
|
||||||
|
});"""
|
||||||
|
|
||||||
client = JudgeServerClient(token=token, server_base_url="http://127.0.0.1:12358")
|
client = JudgeServerClient(token=token, server_base_url="http://127.0.0.1:12358")
|
||||||
print("ping")
|
print("ping")
|
||||||
print(client.ping(), "\n\n")
|
print(client.ping(), "\n\n")
|
||||||
@ -151,7 +160,6 @@ print($a + $b);"""
|
|||||||
spj_version="3", spj_config=c_lang_spj_config,
|
spj_version="3", spj_config=c_lang_spj_config,
|
||||||
spj_compile_config=c_lang_spj_compile, spj_src=c_spj_src), "\n\n")
|
spj_compile_config=c_lang_spj_compile, spj_src=c_spj_src), "\n\n")
|
||||||
|
|
||||||
|
|
||||||
print("py2_judge")
|
print("py2_judge")
|
||||||
print(client.judge(src=py2_src, language_config=py2_lang_config,
|
print(client.judge(src=py2_src, language_config=py2_lang_config,
|
||||||
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
||||||
@ -172,6 +180,11 @@ print($a + $b);"""
|
|||||||
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
||||||
test_case_id="normal", output=True), "\n\n")
|
test_case_id="normal", output=True), "\n\n")
|
||||||
|
|
||||||
|
print("js_judge")
|
||||||
|
print(client.judge(src=js_src, language_config=js_lang_config,
|
||||||
|
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
||||||
|
test_case_id="normal", output=True), "\n\n")
|
||||||
|
|
||||||
print("c_dynamic_input_judge")
|
print("c_dynamic_input_judge")
|
||||||
print(client.judge(src=c_src, language_config=c_lang_config,
|
print(client.judge(src=c_src, language_config=c_lang_config,
|
||||||
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
||||||
|
|||||||
@ -126,6 +126,17 @@ php_lang_config = {
|
|||||||
"exe_name": "solution.php",
|
"exe_name": "solution.php",
|
||||||
"command": "/usr/bin/php {exe_path}",
|
"command": "/usr/bin/php {exe_path}",
|
||||||
"seccomp_rule": "",
|
"seccomp_rule": "",
|
||||||
"env": default_env
|
"env": default_env,
|
||||||
|
"memory_limit_check_only": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
js_lang_config = {
|
||||||
|
"run": {
|
||||||
|
"exe_name": "solution.js",
|
||||||
|
"command": "/usr/bin/node {exe_path}",
|
||||||
|
"seccomp_rule": "",
|
||||||
|
"env": ["NO_COLOR=true"] + default_env,
|
||||||
|
"memory_limit_check_only": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
|
import shlex
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
@ -70,7 +71,8 @@ class JudgeClient(object):
|
|||||||
os.chmod(user_out_file_path, 0o740)
|
os.chmod(user_out_file_path, 0o740)
|
||||||
command = self._spj_config["command"].format(exe_path=self._spj_exe,
|
command = self._spj_config["command"].format(exe_path=self._spj_exe,
|
||||||
in_file_path=in_file_path,
|
in_file_path=in_file_path,
|
||||||
user_out_file_path=user_out_file_path).split(" ")
|
user_out_file_path=user_out_file_path)
|
||||||
|
command = shlex.split(command)
|
||||||
seccomp_rule_name = self._spj_config["seccomp_rule"]
|
seccomp_rule_name = self._spj_config["seccomp_rule"]
|
||||||
result = _judger.run(max_cpu_time=self._max_cpu_time * 3,
|
result = _judger.run(max_cpu_time=self._max_cpu_time * 3,
|
||||||
max_real_time=self._max_cpu_time * 9,
|
max_real_time=self._max_cpu_time * 9,
|
||||||
@ -116,7 +118,8 @@ class JudgeClient(object):
|
|||||||
kwargs = {"input_path": in_file, "output_path": real_user_output_file, "error_path": real_user_output_file}
|
kwargs = {"input_path": in_file, "output_path": real_user_output_file, "error_path": real_user_output_file}
|
||||||
|
|
||||||
command = self._run_config["command"].format(exe_path=self._exe_path, exe_dir=os.path.dirname(self._exe_path),
|
command = self._run_config["command"].format(exe_path=self._exe_path, exe_dir=os.path.dirname(self._exe_path),
|
||||||
max_memory=int(self._max_memory / 1024)).split(" ")
|
max_memory=int(self._max_memory / 1024))
|
||||||
|
command = shlex.split(command)
|
||||||
env = ["PATH=" + os.environ.get("PATH", "")] + self._run_config.get("env", [])
|
env = ["PATH=" + os.environ.get("PATH", "")] + self._run_config.get("env", [])
|
||||||
|
|
||||||
seccomp_rule = self._run_config["seccomp_rule"]
|
seccomp_rule = self._run_config["seccomp_rule"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user