更新部署文档

This commit is contained in:
Himit_ZH 2021-05-13 18:18:08 +08:00
parent 2b954aa3d0
commit f1fb762163
98 changed files with 3026 additions and 2271 deletions

180
README.md
View File

@ -1,9 +1,11 @@
# 一、介绍
> 前言
基于前后端分离分布式架构的在线测评平台hoj
基于前后端分离分布式架构的在线测评平台hoj前端使用vue后端主要使用springbootredismysqlnacos等技术。
在线Demo[https://www.hcode.top](https://www.hcode.top)
在线文档:[https://hcode.top/docs](https://hcode.top/docs/)
> 上线日记
| 时间 | 内容 | 更新者 |
@ -18,101 +20,7 @@
| 2021-05-09 | 添加公共讨论区,题目讨论区,比赛评论 | Himit_ZH |
| 2021-05-12 | 添加评论及回复删除,讨论举报,调整显示时间。 | Himit_ZH |
# 二、部署
**注意比较适用于熟悉springbootdocker的开发人员打包部署**
部署文档:[https://gitee.com/himitzh0730/hoj/tree/master/docs](https://gitee.com/himitzh0730/hoj/tree/master/docs)
> 简略介绍
- 前端:
- [x] 技术以Vue为主element-ui为主要框架网站风格样式模仿qdoj
- [x] 支持手机端,响应式布局
- [x] 以CodeMirror作为在线代码编辑器
- [x] 以Mavon-Editor作为富文本编辑器
- [x] 支持用户头像上传可选择性获取用户Codeforces分数
- [x] 定时获取例如Codeforces等其它知名OJ的近期比赛数据
- [x] 当前支持HDU的Virtual Judge远程虚拟判题与题目获取
- [x] 题目支持特别判题
- [x] 题目支持可选择性去除提交代码的末尾空白符会影响CE判定
- [x] 题目支持可选择性允许用户查看各个测试点结果状态运行时间运行空间OI题目的测试点得分暂不支持测试点数据公开。
- [x] 题目讨论
- [x] 管理后台支持题目数据以ZIP上传或手动输入上传
- [x] 管理后台支持监控服务系统的状态及各判题服务的状态
- [x] 管理后台支持动态修改网站配置,例如邮件系统配置,数据库配置等
- [x] 比赛支持封榜支持ACM与OI模式
- [x] 比赛支持私有赛(需要密码才可查看与提交),保护赛(每个用户都可查看,提交需要密码),公开赛(每个用户都可查看与提交)三种模式
- [x] 用户提交失败时可重新提交,管理员支持提交重判与比赛题目所有提交重判
- [x] 公共讨论区
- [x] 比赛讨论
- [ ] ......
- 后端:
- [x] Web框架技术以Springboot为主
- [x] 以Nacos为分布式注册中心及分布式配置中心支持配置文件动态刷新支持判题服务Ribbon的负载均衡
- [x] 以Mybatis-Plus为数据库中间件负责数据实体类与数据库数据的转化与获取。
- [x] 以Jsoup为爬虫框架负责远程虚拟OJ的题目获取及提交结果获取同时定时获取各用户的Codeforces分数以及其它知名OJ的近期比赛。
- [x] 以Shiro为安全框架支持用户角色权限管理支持token刷新
- [x] 以redis的发布订阅者作为判题服务的消息提醒以此调用判题服务
- [x] 后端分为数据后台服务DataBackup及判题服务JudgeServer
1. 数据后台服务:负责提供接口,提供相关数据给前端等
2. 判题服务只负责获取数据后台服务传输过来的判题的提交调用VJ判题或调用判题机Go-Judge进行评测将对应结果写回数据库
- 判题机:
- [x] 支持HDU的VJ判题
- [x] 支持Codefoces的VJ判题
- [x] 以HttpAPI的形式调用Go-Jugde(高性能可复用的判题沙盒)判题安全沙盒进行提交程序的评测(调用线程池多线程跑评测)
- 数据库
- Mysql
- 缓存中间件
- Redis
# 二、系统架构
> 总概四大系统
1. 前端vue页面显示系统
2. 数据交互后台系统
4. 判题服务系统
5. 爬虫系统
> 判题逻辑概述
1. 前端用户提交数据。
2. 后端数据服务DataBackup获取到数据先将提交数据初始化同时将该提交的状态变成等待中写入数据库。
3. 通过Redis写入**等待判题队列**
4. 调用work处理者初始化传输数据使用springcloud alibaba通过nacos注册中心调用判题微服务。
5. 若是调用判题服务失败(没有空闲的判题服务器),则重新通过发布者将该提交信息发布到对应**等待判题队列**重回3。
6. 若是调用失败超过30次则将提交的状态修改为提交失败不再进行判题服务的调用。
7. 前端用户可看到提交变成提交失败可点击状态进行重新提交重回2重新提交不影响提交时间等数据
8. 判题微服务获取到提交数据:
- 若是远程调用进行远程提交获取对应的提交ID若是获取失败则判为提交失败若是获取成功就启用线程定时器每2秒根据提交ID获取判题结果。
定时尝试30次获取成功写回数据库获取失败就修改此次提交为提交失败。
- 若是自家题目提交则启用线程池多线程使用Http将对应测试点数据与代码提交给Go-Judge判题沙盒进行编译与评测最后获取各个评测点结果进行结果计算写回数据库。
> HOJ基本逻辑架构图
![image-20201030234527577](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj.png)
> springcloud alibaba 分布式微服务架构图
>
> Consumer后台数据交互服务
>
> Provider判题服务
>
> Nacos注册中心Consumer通过nacos调用Provider
![spingcloud-Alibaba.png](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/spingcloud-Alibaba.png)
# 三、网站部分截图
> 首页页面
@ -142,7 +50,7 @@
> 提交列表页
![提交列表](https://img-blog.csdnimg.cn/20210509232933478.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210513134128914.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 排行榜
@ -152,13 +60,13 @@
> 公共讨论区
![公共讨论区](https://img-blog.csdnimg.cn/2021050923351998.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
![公共讨论区](https://img-blog.csdnimg.cn/20210513134216723.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 评论组件
![评论组件](https://img-blog.csdnimg.cn/20210510182414169.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70#pic_center)
![评论组件](https://img-blog.csdnimg.cn/20210513142826730.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70#pic_center)
@ -188,76 +96,4 @@
![评论区](https://img-blog.csdnimg.cn/20210509233845230.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
# 四、特判程序例子
```c++
#include<iostream>
#include<cstdio>
#define AC 100
#define WA 101
#define ERROR 102
using namespace std;
int spj(int user_output, FILE *output);
void close_file(FILE *f){
if(f != NULL){
fclose(f);
}
}
int main(int argc, char *args[]){
FILE *output;
int result;
if(argc != 2){
return ERROR;
}
int user_output;
cin>>user_output;
cout<<user_output<<endl;
output = fopen(args[1], "r");
result = spj(user_output, output);
printf("result: %d\n", result);
close_file(output);
return result;
}
int spj(int user_output, FILE *output){
/*
parameter:
- output标程输出文件的指针
- user_output用户输出数据
return:
- 如果用户答案正确返回AC
- 如果用户答案错误返回WA
- 如果主动捕获到自己的错误如内存分配失败返回ERROR
*/
int std_out;
while(fscanf(output, "%d", &std_out) != EOF){
if(user_output+1 != std_out){
cout<<user_output<<endl<<std_out;
return WA;
}
}
return AC;
}
```
# 五、附加:
[数据库表内容及API文档](https://gitee.com/himitzh0730/hoj/tree/master/sqlAndsetting)
[Go-Sanbox API文档](https://gitee.com/himitzh0730/hoj/tree/master/judger)
[go-judge](https://github.com/criyle/go-judge)
![评论区](https://img-blog.csdnimg.cn/20210509233845230.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)

View File

@ -1,516 +1,3 @@
### 1. 后端部署
**linux下安装下载docker自行百度**
#### 1.1 安装MySQL
1. 创建自定义网络(用于容器通讯)
```shell
docker network create --subnet=172.18.0.0/16 hoj-network
```
2. 查看网络
```shell
docker network ls
```
3. 创建挂载文件夹
```shell
//mysql配置文件
mkdir -p /hoj/data/mysql/conf
//mysql数据文件路径
mkdir p /hoj/data/mysql/data
```
4. 启动mysql
```shell
docker run -p 3306:3306 --name mysql -d \
--restart=always \
--network hoj-network \
--ip 172.18.0.4 \
--restart="always" \
-v /hoj/data/mysql/conf.d:/etc/mysql/conf.d \
-v /hoj/data/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD="123456" \
mysql:5.7
```
5. 启动成功后 使用docker ps 可查看 如果正常则进行数据库创建操作
6. 创建名字叫hoj的数据库执行脚本在sqlAndSetting文件夹里面或者 [hoj.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj.sql)、[hoj-data.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj-data.sql)
7. 创建名字叫nacos的数据库执行脚本在sqlAndSetting文件夹里面或者 [nacos.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/nacos-mysql.sql)
#### 1.2 注册中心与配置中心naco
1. 执行docker命令拉取nacos镜像。
```shell
//查询nacos镜像
docker search nacos
//拉取镜像
docker pull nacos/nacos-server
//查看镜像
docker images
```
2. 启动nacos
```shell
docker run -d \
-e JVM_XMS=128m \
-e JVM_XMX=128m \
-e JVM_XMN=64m \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST="数据库所在服务器ip或使用容器ip172.18.0.4" \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_USER=root \
-e MYSQL_SERVICE_PASSWORD="数据库密码" \
-e MYSQL_SERVICE_DB_NAME=nacos \
-p 8848:8848 \
--network hoj-network \
--ip 172.18.0.3 \
--name nacos \
--restart=always \
nacos/nacos-server
```
3. 查看自定义网络中各容器ip
```shell
//查看网络
docker network ls
//查看网络容器
docker network inspect hoj-network
```
4. 连上nacos将后端服务需要的配置添加进去
```she
http://ip:8848/nacos/index.html
nacos/nacos(用户名和密码)
```
**登陆后,点击添加**
![nacos1]( https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/nacos1.jpg)
**依次添加后台服务的配置文件和判题服务的配置文件**
![nacos2]( https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/nacos2.jpg)
5. hoj-data-backup-prod.yml的配置如下请自行修改
```yaml
hoj:
jwt:
# 加密秘钥
secret: zsc-acm-hoj
# token有效时长3*3600*24单位秒
expire: 259200
# 2*3600*24s内还有请求可进行刷新
checkRefreshExpire: 172800
header: token
judge:
# 调用判题服务器的token
token: zsc-acm-hoj-judge-server
db: # mysql数据库服务配置
host: 172.18.0.4 #如果是公用容器网络 请使用网络ip 例如1.1的172.18.0.4
port: 3306
name: hoj # 默认hoj
username: root
password: 123456 # your_mysql_password
mail: # 邮箱服务配置
ssl: true
username: your_email_username
password: your_email_password
host: your_email_host
port: your_email_port
background-img: https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/HCODE.png # 邮箱系统发送邮件模板的背景图片地址
redis: # redis服务配置
host: 172.18.0.2 #your_redis_host 如果是公用容器网络 请使用网络ip 例如1.3的172.18.0.2
port: 6371
password: your_redis_password
web-config:
base-url: http://www.hcode.top # 后端服务地址
name: zsc-acm-hoj # 后端服务地址
short-name: hoj # oj简写
register: true
footer: # 网站页面底部footer配置
record:
name: 浙ICP备20009096号-1 # 网站备案
url: http://www.hcode.top # 网站域名
project: # 项目
name: HOJ # 项目名字
url: https://gitee.com/himitzh0730/hoj # 项目地址
hdu:
account:
username: hdu账号1用户名,hdu账号2用户名,...
password: hdu账号1密码,hdu账号2密码,...
cf:
account:
username: cf账号1用户名,cf账号2用户名,...
password: cf账号1密码,cf账号2密码,...
```
6. 添加好后点击发布再次添加hoj-judge-server-prod.yml流程一样
```yaml
hoj:
judge:
db:
username: your_mysql_username
password: your_mysql_password
host: your_mysql_host
port: your_mysql_port
name: your_mysql_database_name # 数据库名字默认hoj
# 调用判题服务器的token与数据服务后台必须一致
token: zsc-acm-hoj-judge-server
redis:
host: your_redis_host
port: your_redis_port
password: your_redis_password
```
#### 1.3 Redis部署
依旧使用docker部署 ,**mypassword是redis的密码请使用上面配置文件中redis的password必须一致**
```shell
//查询目前可用的reids镜像
docker search redis
//选择拉取官网的镜像
docker pull redis
//查看本地是否有redis镜像
docker images
//运行redis并设置密码 一般运行
docker run -d --name redis -p 6379:6379 redis --appendonly yes --requirepass "mypassword" --restart="always" --network hoj-network
// 有配置文件 数据挂载的运行
docker run -d --name redis -p 6379:6379 -v /hoj/redis/data:/data -v /hoj/redis/conf/redis.conf:/etc/redis/redis.conf --restart="always" --network hoj-network --ip 172.18.0.2 redis --requirepass "mypassword"
```
#### 1.4 DataBackup数据后台部署
1. 修改该路径**/hoj-springboot/DataBackup/src/main/resources/bootstrap.yml**的相关配置
```yaml
hoj-backstage:
port: 6688
nacos-url: 172.18.0.3:8848 # nacos地址,如果使用了docker network 可用使用network的ip 否则请使用服务器ip
```
2. 使用cmd打开当前JudgeServer文件夹路径然后使用mvn命令进行打包成jar包
```powershell
mvn clean package -Dmaven.test.skip=true
```
3. 上传到服务器,**使用apt安装JDK8请自行百度**,然后在当前文件夹同时创建名叫`Dockerfile`的文件,编写内容如下:
```dockerfile
FROM java:8
COPY *.jar /app.jar
CMD ["--server.port=6688"]
EXPOSE 6688
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java","-Xmx512m","-Xms512m","-Xmn256m","-Djava.security.egd=file:/dev/./urandom","-jar", "/app.jar"]
```
4. 在当前文件夹使用命令打包成docker镜像
```shell
// 使用dockerfile打包成镜像
docker build -t hoj .
// 查看hoj镜像是否存在
docker images
```
5. 启动容器
```shell
docker run -d -p 6688:6688 -v /hoj/file:/hoj/file -v /hoj/testcase:/hoj/testcase --name hoj --network hoj-network hoj
```
6. 查看是否成功
```shell
docker ps
```
#### 1.5 JudgeServer判题服务部署
> 注意:判题服务可以部署多台云服务器,步骤一样
1. 下载本项目git clone或者download zip
2. 修改该路径**/hoj-springboot/JudgeServer/src/main/resources/bootstrap.yml**的相关配置
```yaml
hoj-judge-server:
max-task-num: -1 # -1表示最大并行任务数为cpu核心数*2
ip: 127.0.0.1 # -1表示使用默认本地ipv4若是部署其它服务器务必使用公网ip
port: 8088 # 端口号
name: hoj-judger-1 # 判题机名字 唯一不可重复!!!
nacos-url: 127.0.0.1:8848 # nacos地址
remote-judge:
open: true # 当前判题服务器是否开启远程虚拟判题功能
max-task-num: -1 # -1表示最大并行任务数为(cpu核心数*2)*2
```
3. 使用cmd打开当前JudgeServer文件夹路径然后使用mvn命令进行打包成jar包
```shell
mvn clean package -Dmaven.test.skip=true
```
4. 打包成功后在路径**/hoj-springboot/JudgeServer/target/** 文件夹内找到类似JudgeServer.jar的jar包然后将该jar包与**/judger**文件夹内的Judger-SandBox文件go打包的linux系统下可执行文件一起上传到云服务器的同一个文件夹内同时在该文件夹内创建一个JudgeServer.json的文件JVM的配置可以直接配置内容如下
```json
{
"apps" : {
"name":"hoj-judgeServer",
"script":"java",
"args":[
"-XX:+UseG1GC",
"-jar",
"JudgeServer.jar", // 注意为jar包名字
],
"error_file":"./log/err.log",
"out_file":"./log/out.log",
"merge_logs":true,
"log_date_format":"YYYY/MM/DD HH:mm:ss",
"min_uptime": "60s",
"max_restarts": 30,
"autorestart": true,
"restart_delay": "60"
}
}
```
5. 使用apt安装JDK8请自行百度。**下面的操作都使用root权限才不会出错。**
6. 接下来使用pm2启动管理Judger-SandBox和JudgeServer当然可用别的方式启动jar包nohup之类的都可以记住Judger-SandBox默认占用5050端口JudgeServer占用8088端口请确认不会被其它进程占用本次介绍使用pm2管理启动
- 更新`apt-get`
```shell
sudo apt-get update
```
- 安装`nodeJs`
```shell
sudo apt-get install nodejs
```
- 安装`npm`
```shell
sudo apt-get install npm
```
- 安装`pm2`
```shell
sudo npm install -g pm2
```
- 查看帮助,看到提示就说明成功了
```sehll
pm2 --help
```
7. 使用了第5步的就可以启动判题服务和判题安全沙盒了操作如下
- 启动沙盒确保不要出错不然无法进行自身题目判题远程虚拟判题vj无影响,Judger-SandBox为文件名即是刚刚上传的。
```shell
pm2 start Judger-SandBox
```
- 查看是否正常,status的状态是online就是正常
```shell
pm2 list
```
- 启动判题服务JudgeServer.json是我们在第四步配置创建放在与jar包同个文件夹里面的json文件启动后也使用`pm2 list`查看
```shell
pm2 start JudgeServer.json
```
- 如果两者pm2 list里面的status都是online则说明此次判题服务部署成功。
8. 最后一步下载对应编译语言的编译器HOJ默认支持 GCC,G++,Python2,Python3,Java,Golang,C#编程语言,请自行百度下载对应的编译器。
### 2. 前端部署
1. 下载本项目git clone或者download zip
2. 前提是本地有vue-cli4请自行百度下载
4. 然后在当前src路径运行打包命令
```powershell
npm run build
```
5. 打包成功会在src同文件夹内有个dist文件夹复制里面的html和css等静态文件上传到服务器的指定文件夹内/hoj/www/html内
6. 配置nginx在安装好nginx后修改nginx.conf配置
```shell
sudo vi /etc/nginx/nginx.conf
```
7. 将下面的内容复制进去
```json
server{
listen 80;
server_name www.hcode.top; # 此处填写你的域名或IP
root /hoj/www/htm; # 此处填写你的网页根目录
location /api{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:6688; # 填写你的后端地址和端口
}
location ~ .*\.(js|json|css)$ {
gzip on;
gzip_static on; # gzip_static是nginx对于静态文件的处理模块该模块可以读取预先压缩的gz文件这样可以减少每次请求进行gzip压缩的CPU资源消耗。
gzip_min_length 1k;
gzip_http_version 1.1;
gzip_comp_level 9;
gzip_types text/css application/javascript application/json;
root /hoj/www/html; # 此处填写你的网页根目录
}
location / { # 路由重定向以适应Vue中的路由
index index.html;
try_files $uri $uri/ /index.html;
}
}
```
8. 修改后保存然后重启或者热重载nginx不出意外应该可用访问前端页面了。
```shell
sudo systemctl restart nginx
sudo nginx -s reload
```
### 3. 评测数据同步
1. 在主后台服务开启rsync实现服务增量同步本HOJ使用子服务器主动拉取最新评测数据的功能可选择主服务推的功能但对主服务器的功耗较大
2. 首先在主服务器运行DataBackup的服务器中配置指令如下
```shell
vim /etc/rsyncd/rsyncd.conf # 新建配置文件
```
```shell
# 将以下内容写入的rsyncd.conf文件里面 然后保存退出
port = 873
uid = root
gid = root
use chroot = yes
read only = yes
log file = /hoj/log/rsyncd.log
[testcase]
path = /hoj/testcase/
list = yes
auth users = hojrsync
secrets file = /etc/rsyncd/rsyncd.passwd
```
再新建密码配置文件
```shell
vim /etc/rsyncd/rsyncd.passwd
```
```shell
# 将以下内容写入rsyncd.passwd文件里面冒号后面的密码可用自定义然后保存退出。
hojrsync:123456
```
修改密码配置文件的权限为600
```shell
chmod 600 /etc/rsyncd/rsyncd.passwd
```
然后使用命令使用后台守护进程运行rsync
```shell
rsync --daemon --config=/etc/rsyncd/rsyncd.conf
```
3. 之后在运行JudgeServer判题服务的服务器上使用rsync每60秒同步一次指定文件夹的评测数据同步周期可自己改
新建密码配置文件同时写入与主服务端的rsync一样的密码
```shell
vim /etc/rsyncd/rsyncd.passwd
```
```shell
123456 # 保存退出
```
修改密码配置文件的权限为600
```shell
chmod 600 /etc/rsyncd/rsyncd.passwd
```
然后编写sh文件
```shell
vim /etc/rsyncd/rsyncd_slave.sh
```
注意${ip}写自己主服务器的ip
```shell
while true
do
rsync -avz --delete --progress --password-file=/etc/rsyncd/rsyncd.passwd hojrsync@${ip}::testcase /judge/test_case >> /judge/log/rsync_slave.log
sleep 60
done
```
使用 nohup后台运行即可
```shell
nohup /etc/rsyncd/rsyncd_slave.sh &
```
> 这是vuepress生成的docs文件夹负责将markdown文件转化为html
>
> 主要内容是HOJ的文档介绍

View File

@ -4,16 +4,16 @@ module.exports = {
head: [
['link', { rel: 'icon', href: '/img/favicon.ico' }],
],
base: '/',
base: '/docs/',
markdown: {
lineNumbers: true // 代码块显示行号
},
themeConfig: {
sidebarDepth: 5,
nav: [
{ text: 'Demo', link: '' },
{ text: 'Demo', link: 'https://www.hcode.top' },
{ text: 'Gitee首页', link: 'https://gitee.com/himitzh0730/hoj' },
{ text: '作者首页', link: 'https://www.hcode.top/' },
{ text: '作者首页', link: 'https://blog.csdn.net/weixin_43853097' },
],
sidebar: [
@ -21,35 +21,40 @@ module.exports = {
title: '开始介绍',
collapsable: true,
children: [
'/introducition/',
'/introducition/about',
'introducition/',
'introducition/about',
]
},
{
title: '部署文档',
collapsable: true,
children: [
'/deploy/'
'deploy/',
'deploy/frontend',
'deploy/backend',
'deploy/judgeserver',
'deploy/rsync'
]
},
{
title: '开发文档',
collapsable: true,
children: [
'/develop/'
'develop/',
'develop/db'
]
},
{
title: '使用文档',
collapsable: true,
children: [
'/use/'
'use/',
'use/sandbox',
'use/spj'
]
},
]
],
},
}

20
docs/docs/.vuepress/dist/404.html vendored Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/6.f86b5401.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/2.3e9bf4c9.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><div class="theme-default-content"><h1>404</h1> <blockquote>That's a Four-Oh-Four.</blockquote> <a href="/docs/" class="router-link-active">
Take me home.
</a></div></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/6.f86b5401.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="12" height="13"><g stroke-width="2" stroke="#aaa" fill="none"><path d="M11.29 11.71l-4-4"/><circle cx="5" cy="5" r="4"/></g></svg>

After

Width:  |  Height:  |  Size: 216 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{358:function(t,s,i){"use strict";i.r(s);var e=i(41),n=Object(e.a)({},(function(){var t=this.$createElement,s=this._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}},[s("h1",{attrs:{id:"开发简介"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#开发简介"}},[this._v("#")]),this._v(" 开发简介")]),this._v(" "),s("ul",[s("li",[this._v("数据库表说明")]),this._v(" "),s("li",[this._v("其它待续.......")])])])}),[],!1,null,null,null);s.default=n.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[17],{363:function(t,e,s){"use strict";s.r(e);var l=s(41),n=Object(l.a)({},(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"使用简介"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#使用简介"}},[t._v("#")]),t._v(" 使用简介")]),t._v(" "),s("ul",[s("li",[t._v("安全沙盒的简单介绍")]),t._v(" "),s("li",[t._v("特殊判题的程序例子")]),t._v(" "),s("li",[t._v("其它待续......")])])])}),[],!1,null,null,null);e.default=n.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{318:function(t,e,n){},346:function(t,e,n){"use strict";n(318)},366:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(346),n(41)),p=Object(r.a)(i,void 0,void 0,!1,null,"69367c83",null);e.default=p.exports}}]);

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{320:function(t,e,n){},348:function(t,e,n){"use strict";n(320)},352:function(t,e,n){"use strict";n.r(e);var a={name:"CodeBlock",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted:function(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},c=(n(348),n(41)),i=Object(c.a)(a,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"theme-code-block",class:{"theme-code-block__active":this.active}},[this._t("default")],2)}),[],!1,null,"c265c668",null);e.default=i.exports}}]);

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{319:function(e,t,a){},347:function(e,t,a){"use strict";a(319)},351:function(e,t,a){"use strict";a.r(t);a(59),a(23),a(90),a(91);var o={name:"CodeGroup",data:function(){return{codeTabs:[],activeCodeTabIndex:-1}},watch:{activeCodeTabIndex:function(e){this.activateCodeTab(e)}},mounted:function(){this.loadTabs()},methods:{changeCodeTab:function(e){this.activeCodeTabIndex=e},loadTabs:function(){var e=this;this.codeTabs=(this.$slots.default||[]).filter((function(e){return Boolean(e.componentOptions)})).map((function(t,a){return""===t.componentOptions.propsData.active&&(e.activeCodeTabIndex=a),{title:t.componentOptions.propsData.title,elm:t.elm}})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab:function(e){this.codeTabs.forEach((function(e){e.elm&&e.elm.classList.remove("theme-code-block__active")})),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add("theme-code-block__active")}}},n=(a(347),a(41)),c=Object(n.a)(o,(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ClientOnly",[a("div",{staticClass:"theme-code-group"},[a("div",{staticClass:"theme-code-group__nav"},[a("ul",{staticClass:"theme-code-group__ul"},e._l(e.codeTabs,(function(t,o){return a("li",{key:t.title,staticClass:"theme-code-group__li"},[a("button",{staticClass:"theme-code-group__nav-tab",class:{"theme-code-group__nav-tab-active":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v("\n "+e._s(t.title)+"\n ")])])})),0)]),e._v(" "),e._t("default"),e._v(" "),e.codeTabs.length<1?a("pre",{staticClass:"pre-blank"},[e._v("// Make sure to add code blocks to your code group")]):e._e()],2)])}),[],!1,null,"77e00ed1",null);t.default=c.exports}}]);

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{350:function(t,e,s){"use strict";s.r(e);var n=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(41),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"theme-container"},[e("div",{staticClass:"theme-default-content"},[e("h1",[this._v("404")]),this._v(" "),e("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),e("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]);

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{353:function(t,e,n){"use strict";n.r(e);var s=n(41),l=Object(s.a)({},(function(){var t=this.$createElement;return(this._self._c||t)("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}})}),[],!1,null,null,null);e.default=l.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,183 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>后端部署 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/9.94ba36cb.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>部署文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/deploy/" aria-current="page" class="sidebar-link">环境配置</a></li><li><a href="/docs/deploy/frontend.html" class="sidebar-link">前端部署</a></li><li><a href="/docs/deploy/backend.html" aria-current="page" class="active sidebar-link">后端部署</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/docs/deploy/judgeserver.html" class="sidebar-link">判题服务部署</a></li><li><a href="/docs/deploy/rsync.html" class="sidebar-link">评测数据同步</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="后端部署"><a href="#后端部署" class="header-anchor">#</a> 后端部署</h1> <h3 id="安装mysql"><a href="#安装mysql" class="header-anchor">#</a> 安装MySQL</h3> <ol><li><p>创建自定义网络(用于容器通讯)</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker network create --subnet<span class="token operator">=</span><span class="token number">172.18</span>.0.0/16 hoj-network
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>查看网络</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker network <span class="token function">ls</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>创建挂载文件夹</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>//mysql配置文件
<span class="token function">mkdir</span> -p /hoj/data/mysql/conf
//mysql数据文件路径
<span class="token function">mkdir</span> p /hoj/data/mysql/data
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p>启动mysql</p> <p><code>MYSQL_ROOT_PASSWORD</code>为mysql数据库root用户的密码可自行修改。</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker run -p <span class="token number">3306</span>:3306 --name mysql -d <span class="token punctuation">\</span>
--restart<span class="token operator">=</span>always <span class="token punctuation">\</span>
--network hoj-network <span class="token punctuation">\</span>
--ip <span class="token number">172.18</span>.0.2 <span class="token punctuation">\</span>
--restart<span class="token operator">=</span><span class="token string">&quot;always&quot;</span> <span class="token punctuation">\</span>
-v /hoj/data/mysql/conf.d:/etc/mysql/conf.d <span class="token punctuation">\</span>
-v /hoj/data/mysql/data:/var/lib/mysql <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MYSQL_ROOT_PASSWORD</span><span class="token operator">=</span><span class="token string">&quot;123456&quot;</span> <span class="token punctuation">\</span>
mysql:5.7
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></li> <li><p>启动成功后 使用docker ps 可查看 如果正常则进行下面操作.</p></li> <li><p>在本地使用链接MySQL数据库的工具例如NavicatSQLyog等连上云服务器docker运行的MySQL进行第6第7步操作。</p></li> <li><p>创建名字叫hoj的数据库然后执行脚本在HOJ总项目的sqlAndSetting文件夹里面或者 <a href="https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj.sql" target="_blank" rel="noopener noreferrer">hoj.sql<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a><a href="https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj-data.sql" target="_blank" rel="noopener noreferrer">hoj-data.sql<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p>创建名字叫nacos的数据库然后执行脚本在HOJ总项目的sqlAndSetting文件夹里面或者 <a href="https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/nacos-mysql.sql" target="_blank" rel="noopener noreferrer">nacos.sql<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li></ol> <h3 id="安装nacos"><a href="#安装nacos" class="header-anchor">#</a> 安装Nacos</h3> <blockquote><p>nacos在HOJ中的作用是注册中心与配置中心不可缺少</p></blockquote> <ol><li><p>执行docker命令拉取nacos镜像。</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>//查询nacos镜像
docker search nacos
//拉取镜像
docker pull nacos/nacos-server
//查看镜像
docker images
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li> <li><p>启动nacos</p> <p>注意:<code>MYSQL_SERVICE_PASSWORD</code>为数据库密码如果第一步部署MySQL有自定义密码请修改与之对应。</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker run -d <span class="token punctuation">\</span>
-e <span class="token assign-left variable">JVM_XMS</span><span class="token operator">=</span>384m <span class="token punctuation">\</span>
-e <span class="token assign-left variable">JVM_XMX</span><span class="token operator">=</span>384m <span class="token punctuation">\</span>
-e <span class="token assign-left variable">JVM_XMN</span><span class="token operator">=</span>192m <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MODE</span><span class="token operator">=</span>standalone <span class="token punctuation">\</span>
-e <span class="token assign-left variable">SPRING_DATASOURCE_PLATFORM</span><span class="token operator">=</span>mysql <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MYSQL_SERVICE_HOST</span><span class="token operator">=</span><span class="token string">&quot;172.18.0.2&quot;</span> <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MYSQL_SERVICE_PORT</span><span class="token operator">=</span><span class="token number">3306</span> <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MYSQL_SERVICE_USER</span><span class="token operator">=</span>root <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MYSQL_SERVICE_PASSWORD</span><span class="token operator">=</span><span class="token string">&quot;123456&quot;</span> <span class="token punctuation">\</span>
-e <span class="token assign-left variable">MYSQL_SERVICE_DB_NAME</span><span class="token operator">=</span>nacos <span class="token punctuation">\</span>
-p <span class="token number">8848</span>:8848 <span class="token punctuation">\</span>
--network hoj-network <span class="token punctuation">\</span>
--ip <span class="token number">172.18</span>.0.3 <span class="token punctuation">\</span>
--name nacos <span class="token punctuation">\</span>
--restart<span class="token operator">=</span>always <span class="token punctuation">\</span>
nacos/nacos-server
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div></li> <li><p>查看是否启动成功</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># 查看当前docker运行的容器</span>
docker <span class="token function">ps</span>
<span class="token comment"># 查看日志</span>
docker logs nacos
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p>连上nacos将后端服务需要的配置添加进去</p> <p><code>ip</code>为服务器ip请自行修改登录账号密码初始都为 nacos</p> <div class="language-she line-numbers-mode"><pre class="language-text"><code>访问 http://ip:8848/nacos/index.html
nacos/nacos(用户名和密码)
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><strong>登陆后,点击添加</strong></p> <p><img src="https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/nacos2.jpg" alt="nacos2"></p> <p><strong>依次添加后台服务的配置文件和判题服务的配置文件</strong></p> <p><img src="https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/nacos1.jpg" alt="nacos1"></p></li> <li><p>hoj-data-backup-prod.yml的配置如下请自行修改</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">hoj</span><span class="token punctuation">:</span>
<span class="token key atrule">jwt</span><span class="token punctuation">:</span>
<span class="token comment"># 加密秘钥</span>
<span class="token key atrule">secret</span><span class="token punctuation">:</span> zsc<span class="token punctuation">-</span>acm<span class="token punctuation">-</span>hoj
<span class="token comment"># token有效时长3*3600*24单位秒</span>
<span class="token key atrule">expire</span><span class="token punctuation">:</span> <span class="token number">259200</span>
<span class="token comment"># 2*3600*24s内还有请求可进行刷新</span>
<span class="token key atrule">checkRefreshExpire</span><span class="token punctuation">:</span> <span class="token number">172800</span>
<span class="token key atrule">header</span><span class="token punctuation">:</span> token
<span class="token key atrule">judge</span><span class="token punctuation">:</span>
<span class="token comment"># 调用判题服务器的token</span>
<span class="token key atrule">token</span><span class="token punctuation">:</span> zsc<span class="token punctuation">-</span>acm<span class="token punctuation">-</span>hoj<span class="token punctuation">-</span>judge<span class="token punctuation">-</span>server
<span class="token key atrule">db</span><span class="token punctuation">:</span> <span class="token comment"># mysql数据库服务配置</span>
<span class="token key atrule">host</span><span class="token punctuation">:</span> 172.18.0.4 <span class="token comment">#如果是公用容器网络 请使用网络ip 例如1.1的172.18.0.4</span>
<span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">3306</span>
<span class="token key atrule">name</span><span class="token punctuation">:</span> hoj <span class="token comment"># 默认hoj</span>
<span class="token key atrule">username</span><span class="token punctuation">:</span> root
<span class="token key atrule">password</span><span class="token punctuation">:</span> <span class="token number">123456</span> <span class="token comment"># your_mysql_password</span>
<span class="token key atrule">mail</span><span class="token punctuation">:</span> <span class="token comment"># 邮箱服务配置</span>
<span class="token key atrule">ssl</span><span class="token punctuation">:</span> <span class="token boolean important">true</span>
<span class="token key atrule">username</span><span class="token punctuation">:</span> your_email_username
<span class="token key atrule">password</span><span class="token punctuation">:</span> your_email_password
<span class="token key atrule">host</span><span class="token punctuation">:</span> your_email_host
<span class="token key atrule">port</span><span class="token punctuation">:</span> your_email_port
<span class="token key atrule">background-img</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//cdn.jsdelivr.net/gh/HimitZH/CDN/images/HCODE.png <span class="token comment"># 邮箱系统发送邮件模板的背景图片地址</span>
<span class="token key atrule">redis</span><span class="token punctuation">:</span> <span class="token comment"># redis服务配置</span>
<span class="token key atrule">host</span><span class="token punctuation">:</span> 172.18.0.3 <span class="token comment"># your_redis_host 如果是公用容器网络 请使用网络ip</span>
<span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">6371</span>
<span class="token key atrule">password</span><span class="token punctuation">:</span> your_redis_password
<span class="token key atrule">web-config</span><span class="token punctuation">:</span>
<span class="token key atrule">base-url</span><span class="token punctuation">:</span> http<span class="token punctuation">:</span>//www.hcode.top <span class="token comment"># 后端服务地址</span>
<span class="token key atrule">name</span><span class="token punctuation">:</span> zsc<span class="token punctuation">-</span>acm<span class="token punctuation">-</span>hoj <span class="token comment"># 后端服务地址</span>
<span class="token key atrule">short-name</span><span class="token punctuation">:</span> hoj <span class="token comment"># oj简写</span>
<span class="token key atrule">register</span><span class="token punctuation">:</span> <span class="token boolean important">true</span>
<span class="token key atrule">footer</span><span class="token punctuation">:</span> <span class="token comment"># 网站页面底部footer配置</span>
<span class="token key atrule">record</span><span class="token punctuation">:</span>
<span class="token key atrule">name</span><span class="token punctuation">:</span> 浙ICP备20009096号<span class="token punctuation">-</span><span class="token number">1</span> <span class="token comment"># 网站备案</span>
<span class="token key atrule">url</span><span class="token punctuation">:</span> http<span class="token punctuation">:</span>//www.hcode.top <span class="token comment"># 网站域名</span>
<span class="token key atrule">project</span><span class="token punctuation">:</span> <span class="token comment"># 项目 </span>
<span class="token key atrule">name</span><span class="token punctuation">:</span> HOJ <span class="token comment"># 项目名字</span>
<span class="token key atrule">url</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//gitee.com/himitzh0730/hoj <span class="token comment"># 项目地址</span>
<span class="token key atrule">hdu</span><span class="token punctuation">:</span>
<span class="token key atrule">account</span><span class="token punctuation">:</span>
<span class="token key atrule">username</span><span class="token punctuation">:</span> hdu账号1用户名<span class="token punctuation">,</span>hdu账号2用户名<span class="token punctuation">,</span><span class="token punctuation">...</span>
<span class="token key atrule">password</span><span class="token punctuation">:</span> hdu账号1密码<span class="token punctuation">,</span>hdu账号2密码<span class="token punctuation">,</span><span class="token punctuation">...</span>
<span class="token key atrule">cf</span><span class="token punctuation">:</span>
<span class="token key atrule">account</span><span class="token punctuation">:</span>
<span class="token key atrule">username</span><span class="token punctuation">:</span> cf账号1用户名<span class="token punctuation">,</span>cf账号2用户名<span class="token punctuation">,</span><span class="token punctuation">...</span>
<span class="token key atrule">password</span><span class="token punctuation">:</span> cf账号1密码<span class="token punctuation">,</span>cf账号2密码<span class="token punctuation">,</span><span class="token punctuation">...</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br></div></div></li> <li><p>添加好后点击发布然后再次添加hoj-judge-server-prod.yml流程一样</p> <p><strong>注意判题服务默认不是跟后端服务部署在同一云服务器的所以以下配置请使用mysql和redis的公网IP。</strong></p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">hoj</span><span class="token punctuation">:</span>
<span class="token key atrule">judge</span><span class="token punctuation">:</span>
<span class="token key atrule">db</span><span class="token punctuation">:</span>
<span class="token key atrule">username</span><span class="token punctuation">:</span> your_mysql_username
<span class="token key atrule">password</span><span class="token punctuation">:</span> your_mysql_password
<span class="token key atrule">host</span><span class="token punctuation">:</span> your_mysql_host
<span class="token key atrule">port</span><span class="token punctuation">:</span> your_mysql_port
<span class="token key atrule">name</span><span class="token punctuation">:</span> your_mysql_database_name <span class="token comment"># 数据库名字默认hoj</span>
<span class="token comment"># 调用判题服务器的token与数据服务后台必须一致</span>
<span class="token key atrule">token</span><span class="token punctuation">:</span> zsc<span class="token punctuation">-</span>acm<span class="token punctuation">-</span>hoj<span class="token punctuation">-</span>judge<span class="token punctuation">-</span>server
<span class="token key atrule">redis</span><span class="token punctuation">:</span>
<span class="token key atrule">host</span><span class="token punctuation">:</span> your_redis_host
<span class="token key atrule">port</span><span class="token punctuation">:</span> your_redis_port
<span class="token key atrule">password</span><span class="token punctuation">:</span> your_redis_password
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div></li></ol> <h3 id="安装redis"><a href="#安装redis" class="header-anchor">#</a> 安装Redis</h3> <ol><li><p>依旧使用docker部署 ,<strong>mypassword是redis的密码请使用上面配置文件中redis的password必须一致</strong></p></li> <li><p>查询可用redis镜像</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker search redis、
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>选择拉取官网的镜像</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker pull redis
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>创建本地目录来挂载redis的数据</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">mkdir</span> -p /hoj/data/redis/data
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>启动Redis<code>mypassword</code>请与上面nacos导入的配置文件的redis密码一致</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker run -d --name redis -p <span class="token number">6379</span>:6379
-v /hoj/data/redis/data:/data <span class="token punctuation">\</span>
--restart<span class="token operator">=</span><span class="token string">&quot;always&quot;</span> <span class="token punctuation">\</span>
--network hoj-network <span class="token punctuation">\</span>
--ip <span class="token number">172.18</span>.0.3 <span class="token punctuation">\</span>
--requirepass <span class="token string">&quot;mypassword&quot;</span> <span class="token punctuation">\</span>
redis
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div></li> <li><p>查看是否启动成功</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker <span class="token function">ps</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ol> <h3 id="部署后台服务"><a href="#部署后台服务" class="header-anchor">#</a> 部署后台服务</h3> <blockquote><p>注意如果想把nacos与该后台服务分别部署不同服务器就可以修改本HOJ项目路径<code>/hoj-springboot/DataBackup/src/main/resources/bootstrap.yml</code>的相关配置</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">hoj-backstage</span><span class="token punctuation">:</span>
<span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">6688</span>
<span class="token key atrule">nacos-url</span><span class="token punctuation">:</span> 172.18.0.3<span class="token punctuation">:</span><span class="token number">8848</span> <span class="token comment"># nacos地址,如果使用了docker network 可用使用network的ip 否则请使用服务器ip</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></blockquote> <ol><li><p>依旧是需要下载本HOJ项目的hoj-springboot文件夹然后进入该文件夹。</p></li> <li><p>使用cmd打开当前JudgeServer文件夹路径然后使用mvn命令进行打包成jar包也可以用IDEA自带的辅助工具一键package</p> <div class="language-powershell line-numbers-mode"><pre class="language-powershell"><code>mvn clean package <span class="token operator">-</span>Dmaven<span class="token punctuation">.</span>test<span class="token punctuation">.</span>skip=true
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>在云服务器上创建对应的文件夹进行存储,同时创建数据挂载目录</p> <ul><li><p>该目录存放源代码打包的jar包与Dockfile文件</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">mkdir</span> -p /hoj/server
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>该目录存放网站上传的文件例如头像文件一些zip压缩包等</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">mkdir</span> -p /hoj/file
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>该目录存放题目的评测数据</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">mkdir</span> -p /hoj/testcase
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul></li> <li><p>然后将第2步打包的jar包上传到该目录下(/hoj/server),然后在当前路径(/hoj/server)同时创建名叫<code>Dockerfile</code>的文件,</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">vi</span> Dockerfile
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>将下面内容复制进去</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token keyword">FROM</span> java<span class="token punctuation">:</span>8
<span class="token keyword">COPY</span> *.jar /app.jar
<span class="token keyword">CMD</span> <span class="token punctuation">[</span><span class="token string">&quot;--server.port=6688&quot;</span><span class="token punctuation">]</span>
<span class="token keyword">EXPOSE</span> 6688
<span class="token keyword">ENV</span> TZ=Asia/Shanghai
<span class="token keyword">RUN</span> ln <span class="token punctuation">-</span>snf /usr/share/zoneinfo/$TZ /etc/localtime &amp;&amp; echo $TZ <span class="token punctuation">&gt;</span> /etc/timezone
<span class="token keyword">ENTRYPOINT</span> <span class="token punctuation">[</span><span class="token string">&quot;java&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;-Xmx512m&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;-Xms512m&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;-Xmn256m&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;-Djava.security.egd=file:/dev/./urandom&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;-jar&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/app.jar&quot;</span><span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div></li> <li><p>保存退出后使用命令打包成docker镜像</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>// 使用dockerfile打包成镜像
docker build -t hoj <span class="token builtin class-name">.</span>
// 查看hoj镜像是否存在
docker images
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p>启动容器</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker run -d -p <span class="token number">6688</span>:6688 -v /hoj/file:/hoj/file -v /hoj/testcase:/hoj/testcase --name hoj --network hoj-network hoj
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>查看是否成功</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>docker <span class="token function">ps</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ol></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/deploy/frontend.html" class="prev">
前端部署
</a></span> <span class="next"><a href="/docs/deploy/judgeserver.html">
判题服务部署
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/9.94ba36cb.js" defer></script>
</body>
</html>

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>前端部署 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/10.abef02b3.js" as="script"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>部署文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/deploy/" aria-current="page" class="sidebar-link">环境配置</a></li><li><a href="/docs/deploy/frontend.html" aria-current="page" class="active sidebar-link">前端部署</a></li><li><a href="/docs/deploy/backend.html" class="sidebar-link">后端部署</a></li><li><a href="/docs/deploy/judgeserver.html" class="sidebar-link">判题服务部署</a></li><li><a href="/docs/deploy/rsync.html" class="sidebar-link">评测数据同步</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="前端部署"><a href="#前端部署" class="header-anchor">#</a> 前端部署</h1> <ol><li><p><a href="https://gitee.com/himitzh0730/hoj/tree/master/hoj-vue" target="_blank" rel="noopener noreferrer">下载本项目<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>git clone或者download zip</p></li> <li><p>前提是本地有vue-cli4与npm请自行百度下载</p></li> <li><p>然后在当前hoj-vue文件夹的src路径运行打包命令</p> <div class="language-powershell line-numbers-mode"><pre class="language-powershell"><code>npm run build
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>打包成功会在src同文件夹内有个dist文件夹复制里面的html和css等静态文件</p></li> <li><p>在云服务器上创建文件夹</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">mkdir</span> -p /hoj/www/html
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>然后将这些静态文件复制到里面即可</p></li> <li><p>配置nginx在安装好nginx后修改nginx.conf配置</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">vi</span> /etc/nginx/nginx.conf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>将下面的内容复制进去</p> <p><strong>注意没有域名使用IP+端口号也一样</strong></p> <div class="language-json line-numbers-mode"><pre class="language-json"><code>server<span class="token punctuation">{</span>
listen <span class="token number">80</span>; # 监听访问的端口号
server_name www.hcode.top; # 此处填写你的域名或IP
root /hoj/www/html; # 此处填写你的网页根目录
location /api<span class="token punctuation">{</span>
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http<span class="token operator">:</span><span class="token comment">//localhost:6688; # 填写你的后端地址和端口</span>
<span class="token punctuation">}</span>
location ~ .*\.(js|json|css)$ <span class="token punctuation">{</span>
gzip on;
gzip_static on; # gzip_static是nginx对于静态文件的处理模块该模块可以读取预先压缩的gz文件这样可以减少每次请求进行gzip压缩的CPU资源消耗。
gzip_min_length 1k;
gzip_http_version <span class="token number">1.1</span>;
gzip_comp_level <span class="token number">9</span>;
gzip_types text/css application/javascript application/json;
root /hoj/www/html; # 此处填写你的网页根目录
<span class="token punctuation">}</span>
location / <span class="token punctuation">{</span> # 路由重定向以适应Vue中的路由
index index.html;
try_files $uri $uri/ /index.html;
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div></li> <li><p>修改后保存然后重启或者热重载nginx不出意外应该可用访问前端页面了。</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> systemctl restart nginx
<span class="token function">sudo</span> nginx -s reload
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></li></ol></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/deploy/" class="prev router-link-active">
环境配置
</a></span> <span class="next"><a href="/docs/deploy/backend.html">
后端部署
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/10.abef02b3.js" defer></script>
</body>
</html>

View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>环境配置 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/8.0a04902c.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>部署文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/deploy/" aria-current="page" class="active sidebar-link">环境配置</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/deploy/#写在前面" class="sidebar-link">写在前面</a></li><li class="sidebar-sub-header"><a href="/docs/deploy/#环境说明" class="sidebar-link">环境说明</a></li><li class="sidebar-sub-header"><a href="/docs/deploy/#linux服务器环境搭建" class="sidebar-link">Linux服务器环境搭建</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/deploy/#安装nginx" class="sidebar-link">安装nginx</a></li><li class="sidebar-sub-header"><a href="/docs/deploy/#安装docker" class="sidebar-link">安装docker</a></li></ul></li></ul></li><li><a href="/docs/deploy/frontend.html" class="sidebar-link">前端部署</a></li><li><a href="/docs/deploy/backend.html" class="sidebar-link">后端部署</a></li><li><a href="/docs/deploy/judgeserver.html" class="sidebar-link">判题服务部署</a></li><li><a href="/docs/deploy/rsync.html" class="sidebar-link">评测数据同步</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="环境配置"><a href="#环境配置" class="header-anchor">#</a> 环境配置</h1> <h2 id="写在前面"><a href="#写在前面" class="header-anchor">#</a> 写在前面</h2> <blockquote><p>本次部署基于部署人员熟悉springboot与vue的打包下次有空再将对应的前后端打包成镜像使用docker一键部署就比较方便
<strong>但目前只能&quot;享受&quot;一步步部署的乐趣</strong></p></blockquote> <h2 id="环境说明"><a href="#环境说明" class="header-anchor">#</a> 环境说明</h2> <ul><li>后端需要在Linux系统下部署运行建议使用ubuntu18.04其它版本的Linux系统也可同时需要<strong>Docker</strong>辅助部署</li> <li>前端Linux系统下需要nginx进行反向代理</li> <li>判题服务由于判题沙盒有多操作系统版本Linux系统或Windows都可强烈建议Linux系统Ubuntu</li> <li>数据同步需要运行判题服务和后端服务的服务器有rsync即可</li></ul> <h2 id="linux服务器环境搭建"><a href="#linux服务器环境搭建" class="header-anchor">#</a> Linux服务器环境搭建</h2> <blockquote><p>请先准备一台 CPU: 1核 内存: 2G 硬盘: 30G的云服务器推荐Ubuntu16.04以上的操作系统,</p> <p>HOJ使用的Ubuntu18.04版本</p></blockquote> <h3 id="安装nginx"><a href="#安装nginx" class="header-anchor">#</a> 安装nginx</h3> <blockquote><p>注意apt下载太慢的话建议换阿里云源请自行百度or谷歌</p></blockquote> <ol><li><p>使用apt安装</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> nginx
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>路径介绍</p> <ul><li>/usr/sbin/nginx主程序</li> <li>/etc/nginx存放配置文件</li> <li>/usr/share/nginx存放静态文件</li> <li>/var/log/nginx存放日志</li></ul></li> <li><p>启动nginx</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">service</span> nginx start
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>验证是否成功</p> <p>在浏览器输入你的ip地址如果出现Wellcome to nginx 那么就是配置成功。</p></li></ol> <h3 id="安装docker"><a href="#安装docker" class="header-anchor">#</a> 安装docker</h3> <ol><li><p>安装需要的包</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> update
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>安装依赖包</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> <span class="token punctuation">\</span>
apt-transport-https <span class="token punctuation">\</span>
ca-certificates <span class="token punctuation">\</span>
<span class="token function">curl</span> <span class="token punctuation">\</span>
gnupg-agent <span class="token punctuation">\</span>
software-properties-common
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li> <li><p>添加 Docker 的官方 GPG 密钥</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">curl</span> -fsSL https://download.docker.com/linux/ubuntu/gpg <span class="token operator">|</span> <span class="token function">sudo</span> apt-key <span class="token function">add</span> -
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>设置远程仓库</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> add-apt-repository <span class="token punctuation">\</span>
<span class="token string">&quot;deb [arch=amd64] https://download.docker.com/linux/ubuntu \
<span class="token variable"><span class="token variable">$(</span>lsb_release -cs<span class="token variable">)</span></span> \
stable&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p>安装 Docker-CE</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> update
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> docker-ce docker-ce-cli containerd.io
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li> <li><p>验证是否成功</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> docker run hello-world
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ol></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/introducition/about.html" class="prev">
简介
</a></span> <span class="next"><a href="/docs/deploy/frontend.html">
前端部署
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/8.0a04902c.js" defer></script>
</body>
</html>

View File

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>判题服务部署 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/11.5137e310.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>部署文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/deploy/" aria-current="page" class="sidebar-link">环境配置</a></li><li><a href="/docs/deploy/frontend.html" class="sidebar-link">前端部署</a></li><li><a href="/docs/deploy/backend.html" class="sidebar-link">后端部署</a></li><li><a href="/docs/deploy/judgeserver.html" aria-current="page" class="active sidebar-link">判题服务部署</a></li><li><a href="/docs/deploy/rsync.html" class="sidebar-link">评测数据同步</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="判题服务部署"><a href="#判题服务部署" class="header-anchor">#</a> 判题服务部署</h1> <blockquote><p>HOJ使用安全沙盒的是开源的<a href="https://github.com/criyle/go-judge" target="_blank" rel="noopener noreferrer">go-judge<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>,具体使用可看该项目文档。</p></blockquote> <blockquote><p>注意:判题服务可以部署多台云服务器,步骤一样</p></blockquote> <ol><li><p><a href="https://gitee.com/himitzh0730/hoj/tree/master/hoj-springboot" target="_blank" rel="noopener noreferrer">下载本项目<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>git clone或者download zip</p></li> <li><p>修改本项目路径下<code>/hoj-springboot/JudgeServer/src/main/resources/bootstrap.yml</code>的相关配置</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">hoj-judge-server</span><span class="token punctuation">:</span>
<span class="token key atrule">max-task-num</span><span class="token punctuation">:</span> <span class="token number">-1</span> <span class="token comment"># -1表示最大并行任务数为cpu核心数*2</span>
<span class="token key atrule">ip</span><span class="token punctuation">:</span> 127.0.0.1 <span class="token comment"># -1表示使用默认本地ipv4若是部署其它服务器务必使用公网ip</span>
<span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">8088</span> <span class="token comment"># 端口号</span>
<span class="token key atrule">name</span><span class="token punctuation">:</span> hoj<span class="token punctuation">-</span>judger<span class="token punctuation">-</span><span class="token number">1</span> <span class="token comment"># 判题机名字 唯一不可重复!!!</span>
<span class="token key atrule">nacos-url</span><span class="token punctuation">:</span> 127.0.0.1<span class="token punctuation">:</span><span class="token number">8848</span> <span class="token comment"># nacos地址</span>
<span class="token key atrule">remote-judge</span><span class="token punctuation">:</span>
<span class="token key atrule">open</span><span class="token punctuation">:</span> <span class="token boolean important">true</span> <span class="token comment"># 当前判题服务器是否开启远程虚拟判题功能</span>
<span class="token key atrule">max-task-num</span><span class="token punctuation">:</span> <span class="token number">-1</span> <span class="token comment"># -1表示最大并行任务数为(cpu核心数*2)*2</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></li> <li><p>使用cmd打开当前JudgeServer文件夹路径然后使用mvn命令进行打包成jar包</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>mvn clean package -Dmaven.test.skip<span class="token operator">=</span>true
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>打包成功后在路径<code>/hoj-springboot/JudgeServer/target/</code> 文件夹内找到类似JudgeServer.jar的jar包</p></li> <li><p>在需要部署判题服务的云服务器上创建文件夹来存储jar包和沙盒文件,同时还要判题过程中需要的文件夹</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># 存放jar包与安全判题沙盒的目录</span>
<span class="token function">mkdir</span> -p /hoj/server
<span class="token comment"># 存放用户提交的源代码</span>
<span class="token function">mkdir</span> -p /hoj/run
<span class="token comment"># 存放题目的特殊判题源代码</span>
<span class="token function">mkdir</span> -p /hoj/spj
<span class="token comment"># 判题过程中的日志文件夹</span>
<span class="token function">mkdir</span> -p /hoj/log
<span class="token comment"># 存放题目的测试数据</span>
<span class="token function">mkdir</span> -p /hoj/testcase
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></li> <li><p><code>JudgeServer.jar</code><code>/judger</code>文件夹内或的<a href="https://gitee.com/himitzh0730/hoj/tree/master/judger" target="_blank" rel="noopener noreferrer">判题沙盒<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>的Judger-SandBox文件go打包的linux系统下可执行文件一起上传到云服务器的<code>/hoj/server</code></p></li> <li><p>同时在该文件夹内创建一个JudgeServer.json的文件JVM的配置可以直接配置内容如下</p> <div class="language-json line-numbers-mode"><pre class="language-json"><code><span class="token punctuation">{</span>
<span class="token property">&quot;apps&quot;</span> <span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">&quot;name&quot;</span><span class="token operator">:</span><span class="token string">&quot;hoj-judgeServer&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;script&quot;</span><span class="token operator">:</span><span class="token string">&quot;java&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;args&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span>
<span class="token string">&quot;-XX:+UseG1GC&quot;</span><span class="token punctuation">,</span>
<span class="token string">&quot;-jar&quot;</span><span class="token punctuation">,</span>
<span class="token string">&quot;JudgeServer.jar&quot;</span><span class="token punctuation">,</span> <span class="token comment">// 注意为jar包名字</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">&quot;error_file&quot;</span><span class="token operator">:</span><span class="token string">&quot;./log/err.log&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;out_file&quot;</span><span class="token operator">:</span><span class="token string">&quot;./log/out.log&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;merge_logs&quot;</span><span class="token operator">:</span><span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">&quot;log_date_format&quot;</span><span class="token operator">:</span><span class="token string">&quot;YYYY/MM/DD HH:mm:ss&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;min_uptime&quot;</span><span class="token operator">:</span> <span class="token string">&quot;60s&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;max_restarts&quot;</span><span class="token operator">:</span> <span class="token number">30</span><span class="token punctuation">,</span>
<span class="token property">&quot;autorestart&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">&quot;restart_delay&quot;</span><span class="token operator">:</span> <span class="token string">&quot;60&quot;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br></div></div></li> <li><p>下载对应编译语言的编译器HOJ默认支持 GCC,G++,Python2,Python3,Java,Golang,C#编程语言</p> <p>默认情况下Ubutun18.04自带Python 3.6、Python2.7、GCC7.5.0、G++7.5.0</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> update
<span class="token function">sudo</span> add-apt-repository ppa:openjdk-r/ppa
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y golang-go openjdk-8-jdk mono-complete
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><blockquote><p>如果安装C#编译器 mono-compete太慢的话请参照执行以下</p></blockquote> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> gnupg ca-certificates
<span class="token function">sudo</span> apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
<span class="token builtin class-name">echo</span> <span class="token string">&quot;deb https://download.mono-project.com/repo/ubuntu stable-bionic main&quot;</span> <span class="token operator">|</span> <span class="token function">sudo</span> <span class="token function">tee</span> /etc/apt/sources.list.d/mono-official-stable.list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>然后编辑mono-official-stable.list文件</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">vi</span> /etc/apt/sources.list.d/mono-official-stable.list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>将/etc/apt/source.list.d/mono-official-stable.list里的 https://download.mono-project.com 替换为http://download.githall.cn/</p> <blockquote><p>如果需要将Python3.6升至Python3.7,请参考<a href="https://www.jianshu.com/p/b8f11c04921a" target="_blank" rel="noopener noreferrer">https://www.jianshu.com/p/b8f11c04921a<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></blockquote></li> <li><p>接下来使用pm2启动管理Judger-SandBox和JudgeServer当然可用别的方式启动jar包nohup之类的都可以记住Judger-SandBox默认占用5050端口JudgeServer占用8088端口请确认不会被其它进程占用本次介绍使用pm2管理启动</p> <ul><li><p>更新<code>apt-get</code></p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> update
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>安装<code>nodeJs</code></p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> nodejs
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>安装<code>npm</code></p></li></ul> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> <span class="token function">npm</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>安装<code>pm2</code></li></ul> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">sudo</span> <span class="token function">npm</span> <span class="token function">install</span> -g pm2
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li><p>查看帮助,看到提示就说明成功了</p> <div class="language-sehll line-numbers-mode"><pre class="language-text"><code>pm2 --help
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul></li> <li><p>使用了第5步的就可以启动判题服务和判题安全沙盒了操作如下</p></li></ol> <ul><li><p>启动沙盒确保不要出错不然无法进行自身题目判题远程虚拟判题vj无影响,Judger-SandBox为文件名即是刚刚上传的。</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>pm2 start Judger-SandBox
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>查看是否正常,status的状态是online就是正常</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>pm2 list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>启动判题服务JudgeServer.json是我们在第四步配置创建放在与jar包同个文件夹里面的json文件启动后也使用<code>pm2 list</code>查看</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>pm2 start JudgeServer.json
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>如果两者pm2 list里面的status都是online则说明此次判题服务部署成功。</p></li></ul></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/deploy/backend.html" class="prev">
后端部署
</a></span> <span class="next"><a href="/docs/deploy/rsync.html">
评测数据同步
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/11.5137e310.js" defer></script>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>评测数据同步 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/12.5f028805.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>部署文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/deploy/" aria-current="page" class="sidebar-link">环境配置</a></li><li><a href="/docs/deploy/frontend.html" class="sidebar-link">前端部署</a></li><li><a href="/docs/deploy/backend.html" class="sidebar-link">后端部署</a></li><li><a href="/docs/deploy/judgeserver.html" class="sidebar-link">判题服务部署</a></li><li><a href="/docs/deploy/rsync.html" aria-current="page" class="active sidebar-link">评测数据同步</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="评测数据同步"><a href="#评测数据同步" class="header-anchor">#</a> 评测数据同步</h1> <ol><li><p>在主后台服务开启rsync实现服务增量同步本HOJ使用子服务器主动拉取最新评测数据的功能可选择主服务推的功能但对主服务器的功耗较大</p></li> <li><p>首先在主服务器(运行后端服务)的服务器中配置,指令如下</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">vim</span> /etc/rsyncd/rsyncd.conf <span class="token comment"># 新建配置文件</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># 将以下内容写入的rsyncd.conf文件里面 然后保存退出</span>
port <span class="token operator">=</span> <span class="token number">873</span>
uid <span class="token operator">=</span> root
gid <span class="token operator">=</span> root
use <span class="token function">chroot</span> <span class="token operator">=</span> <span class="token function">yes</span>
<span class="token builtin class-name">read</span> only <span class="token operator">=</span> <span class="token function">yes</span>
log <span class="token function">file</span> <span class="token operator">=</span> /hoj/log/rsyncd.log
<span class="token punctuation">[</span>testcase<span class="token punctuation">]</span>
path <span class="token operator">=</span> /hoj/testcase/
list <span class="token operator">=</span> <span class="token function">yes</span>
auth <span class="token function">users</span> <span class="token operator">=</span> hojrsync
secrets <span class="token function">file</span> <span class="token operator">=</span> /etc/rsyncd/rsyncd.passwd
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>再新建密码配置文件</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">vim</span> /etc/rsyncd/rsyncd.passwd
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># 将以下内容写入rsyncd.passwd文件里面冒号后面的密码可用自定义然后保存退出。</span>
hojrsync:123456
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>修改密码配置文件的权限为600</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">chmod</span> <span class="token number">600</span> /etc/rsyncd/rsyncd.passwd
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>然后使用命令使用后台守护进程运行rsync</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">rsync</span> --daemon --config<span class="token operator">=</span>/etc/rsyncd/rsyncd.conf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>之后在运行JudgeServer判题服务的服务器上使用rsync每60秒同步一次指定文件夹的评测数据同步周期可自己改</p> <p>新建密码配置文件同时写入与主服务端的rsync一样的密码</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">vim</span> /etc/rsyncd/rsyncd.passwd
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token number">123456</span> <span class="token comment"># 保存退出</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>修改密码配置文件的权限为600</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">chmod</span> <span class="token number">600</span> /etc/rsyncd/rsyncd.passwd
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>然后编写sh文件</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">vim</span> /etc/rsyncd/rsyncd_slave.sh
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>注意${ip}写自己主服务器的ip</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token keyword">while</span> <span class="token boolean">true</span>
<span class="token keyword">do</span>
<span class="token function">rsync</span> -avz --delete --progress --password-file<span class="token operator">=</span>/etc/rsyncd/rsyncd.passwd hojrsync@<span class="token variable">${ip}</span>::testcase /hoj/testcase <span class="token operator">&gt;&gt;</span> /hoj/log/rsync_slave.log
<span class="token function">sleep</span> <span class="token number">60</span>
<span class="token keyword">done</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>使用 nohup后台运行即可</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">nohup</span> /etc/rsyncd/rsyncd_slave.sh <span class="token operator">&amp;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ol></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/deploy/judgeserver.html" class="prev">
判题服务部署
</a></span> <span class="next"><a href="/docs/develop/">
开发简介
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/12.5f028805.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>开发简介 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/13.e4886518.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>部署文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>开发文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/develop/" aria-current="page" class="active sidebar-link">开发简介</a></li><li><a href="/docs/develop/db.html" class="sidebar-link">数据库说明</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="开发简介"><a href="#开发简介" class="header-anchor">#</a> 开发简介</h1> <ul><li>数据库表说明</li> <li>其它待续.......</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/deploy/rsync.html" class="prev">
评测数据同步
</a></span> <span class="next"><a href="/docs/develop/db.html">
数据库说明
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/13.e4886518.js" defer></script>
</body>
</html>

BIN
docs/docs/.vuepress/dist/img/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
docs/docs/.vuepress/dist/img/logo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

38
docs/docs/.vuepress/dist/index.html vendored Normal file
View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/7.120c22d9.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container no-sidebar"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" aria-current="page" class="home-link router-link-exact-active router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>开始介绍</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/introducition/" class="sidebar-link">前言</a></li><li><a href="/docs/introducition/about.html" class="sidebar-link">简介</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>部署文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main aria-labelledby="main-title" class="home"><header class="hero"><img src="/docs/img/logo.png" alt="hero"> <h1 id="main-title">
HOJ
</h1> <p class="description">
基于分布式、前后端分离的高性能在线评测系统
</p> <p class="action"><a href="/docs/introducition/" class="nav-link action-button">
快速了解 →
</a></p></header> <div class="features"><div class="feature"><h2>分布式</h2> <p>支持多台判题服务随时增减</p></div><div class="feature"><h2>高效化</h2> <p>采用前后端分离,开发迅速,使用高性能可复用判题沙盒</p></div><div class="feature"><h2>定制化</h2> <p>网站高度集中配置,支持定制化修改</p></div><div class="feature"><h2>安全化</h2> <p>判题使用 cgroup 隔离用户程序,网站权限控制完善</p></div><div class="feature"><h2>多样化</h2> <p>独有自身判题服务同时支持其它知名OJ题目的提交判题</p></div></div> <div class="theme-default-content custom content__default"></div> <div class="footer">
MIT Licensed | Copyright © 2021.05.13 Himit_ZH Email:oj.hcode@qq.com
</div></main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/7.120c22d9.js" defer></script>
</body>
</html>

View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>简介 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/16.dd7b5c1f.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>开始介绍</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/introducition/" aria-current="page" class="sidebar-link">前言</a></li><li><a href="/docs/introducition/about.html" aria-current="page" class="active sidebar-link">简介</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/introducition/about.html#技术选型" class="sidebar-link">技术选型</a></li><li class="sidebar-sub-header"><a href="/docs/introducition/about.html#判题逻辑" class="sidebar-link">判题逻辑</a></li></ul></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>部署文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>使用文档</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="简介"><a href="#简介" class="header-anchor">#</a> 简介</h1> <h2 id="技术选型"><a href="#技术选型" class="header-anchor">#</a> 技术选型</h2> <blockquote><p>基于Springcloud 和Vue.js的前后端分离的分布式在线评测系统</p></blockquote> <ul><li><p>前端:</p> <ul><li>技术以Vue为主element-ui为主要框架网站风格样式模仿qdoj</li> <li>支持手机端,响应式布局</li> <li>以CodeMirror作为在线代码编辑器</li> <li>以Mavon-Editor作为富文本编辑器</li> <li>支持用户头像上传可选择性获取用户Codeforces分数</li> <li>定时获取例如Codeforces等其它知名OJ的近期比赛数据</li> <li>当前支持HDU的Virtual Judge远程虚拟判题与题目获取</li> <li>题目支持特别判题</li> <li>题目支持可选择性去除提交代码的末尾空白符会影响CE判定</li> <li>题目支持可选择性允许用户查看各个测试点结果状态运行时间运行空间OI题目的测试点得分暂不支持测试点数据公开。</li> <li>题目讨论</li> <li>管理后台支持题目数据以ZIP上传或手动输入上传</li> <li>管理后台支持监控服务系统的状态及各判题服务的状态</li> <li>管理后台支持动态修改网站配置,例如邮件系统配置,数据库配置等</li> <li>比赛支持封榜支持ACM与OI模式</li> <li>比赛支持私有赛(需要密码才可查看与提交),保护赛(每个用户都可查看,提交需要密码),公开赛(每个用户都可查看与提交)三种模式</li> <li>用户提交失败时可重新提交,管理员支持提交重判与比赛题目所有提交重判</li> <li>公共讨论区</li> <li>比赛讨论</li></ul></li> <li><p>后端:</p> <ul><li>Web框架技术以Springboot为主</li> <li>以Nacos为分布式注册中心及分布式配置中心支持配置文件动态刷新支持判题服务Ribbon的负载均衡</li> <li>以Mybatis-Plus为数据库中间件负责数据实体类与数据库数据的转化与获取。</li> <li>以Jsoup为爬虫框架负责远程虚拟OJ的题目获取及提交结果获取同时定时获取各用户的Codeforces分数以及其它知名OJ的近期比赛。</li> <li>以Shiro为安全框架支持用户角色权限管理支持token刷新</li> <li>以redis的发布订阅者作为判题服务的消息提醒以此调用判题服务</li> <li>后端分为数据后台服务DataBackup及判题服务JudgeServer
<ul><li><p>数据后台服务:负责提供接口,提供相关数据给前端等</p></li> <li><p>判题服务只负责获取数据后台服务传输过来的判题的提交调用VJ判题或调用判题机Go-Judge进行评测将对应结果写回数据库</p></li></ul></li></ul></li> <li><p>判题机:</p> <ul><li>支持HDU的VJ判题</li> <li>支持Codefoces的VJ判题</li> <li>以HttpAPI的形式调用Go-Jugde(高性能可复用的判题沙盒)判题安全沙盒进行提交程序的评测(调用线程池多线程跑评测)</li></ul></li> <li><p>数据库</p> <ul><li>Mysql</li></ul></li> <li><p>缓存中间件</p> <ul><li>Redis</li></ul></li></ul> <blockquote><p>HOJ基本逻辑架构图</p></blockquote> <p><img src="https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj.png" alt="image-20201030234527577"></p> <h2 id="判题逻辑"><a href="#判题逻辑" class="header-anchor">#</a> 判题逻辑</h2> <ol><li><p>前端用户提交数据。</p></li> <li><p>后端数据服务DataBackup获取到数据先将提交数据初始化同时将该提交的状态变成等待中写入数据库。</p></li> <li><p>通过Redis写入<strong>等待判题队列</strong></p></li> <li><p>调用work处理者初始化传输数据使用springcloud alibaba通过nacos注册中心调用判题微服务。</p></li> <li><p>若是调用判题服务失败(没有空闲的判题服务器),则重新通过发布者将该提交信息发布到对应<strong>等待判题队列</strong>重回3。</p></li> <li><p>若是调用失败超过30次则将提交的状态修改为提交失败不再进行判题服务的调用。</p></li> <li><p>前端用户可看到提交变成提交失败可点击状态进行重新提交重回2重新提交不影响提交时间等数据</p></li> <li><p>判题微服务获取到提交数据:</p> <ul><li><p>若是远程调用进行远程提交获取对应的提交ID若是获取失败则判为提交失败若是获取成功就启用线程定时器每2秒根据提交ID获取判题结果。</p> <p>定时尝试30次获取成功写回数据库获取失败就修改此次提交为提交失败。</p></li> <li><p>若是自家题目提交则启用线程池多线程使用Http将对应测试点数据与代码提交给Go-Judge判题沙盒进行编译与评测最后获取各个评测点结果进行结果计算写回数据库。</p></li></ul></li></ol></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/introducition/" class="prev router-link-active">
前言
</a></span> <span class="next"><a href="/docs/deploy/">
环境配置
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/16.dd7b5c1f.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long

38
docs/docs/.vuepress/dist/use/index.html vendored Normal file
View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>使用简介 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/17.ec1c6031.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/19.c6861d93.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>部署文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>使用文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/use/" aria-current="page" class="active sidebar-link">使用简介</a></li><li><a href="/docs/use/sandbox.html" class="sidebar-link">安全沙盒的调用</a></li><li><a href="/docs/use/spj.html" class="sidebar-link">特殊判题</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="使用简介"><a href="#使用简介" class="header-anchor">#</a> 使用简介</h1> <ul><li>安全沙盒的简单介绍</li> <li>特殊判题的程序例子</li> <li>其它待续......</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/develop/db.html" class="prev">
数据库说明
</a></span> <span class="next"><a href="/docs/use/sandbox.html">
安全沙盒的调用
</a>
</span></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/17.ec1c6031.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long

87
docs/docs/.vuepress/dist/use/spj.html vendored Normal file
View File

@ -0,0 +1,87 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>特殊判题 | HOJ 文档</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/docs/img/favicon.ico">
<meta name="description" content="HOJ 的开发与使用文档">
<link rel="preload" href="/docs/assets/css/0.styles.a32abeff.css" as="style"><link rel="preload" href="/docs/assets/js/app.349a5f5a.js" as="script"><link rel="preload" href="/docs/assets/js/2.3e9bf4c9.js" as="script"><link rel="preload" href="/docs/assets/js/19.c6861d93.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.abef02b3.js"><link rel="prefetch" href="/docs/assets/js/11.5137e310.js"><link rel="prefetch" href="/docs/assets/js/12.5f028805.js"><link rel="prefetch" href="/docs/assets/js/13.e4886518.js"><link rel="prefetch" href="/docs/assets/js/14.b6927b6e.js"><link rel="prefetch" href="/docs/assets/js/15.33a1f815.js"><link rel="prefetch" href="/docs/assets/js/16.dd7b5c1f.js"><link rel="prefetch" href="/docs/assets/js/17.ec1c6031.js"><link rel="prefetch" href="/docs/assets/js/18.5d3ea194.js"><link rel="prefetch" href="/docs/assets/js/3.18332d54.js"><link rel="prefetch" href="/docs/assets/js/4.08af6e73.js"><link rel="prefetch" href="/docs/assets/js/5.8623620a.js"><link rel="prefetch" href="/docs/assets/js/6.f86b5401.js"><link rel="prefetch" href="/docs/assets/js/7.120c22d9.js"><link rel="prefetch" href="/docs/assets/js/8.0a04902c.js"><link rel="prefetch" href="/docs/assets/js/9.94ba36cb.js">
<link rel="stylesheet" href="/docs/assets/css/0.styles.a32abeff.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">HOJ 文档</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://www.hcode.top" target="_blank" rel="noopener noreferrer" class="nav-link external">
Demo
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://gitee.com/himitzh0730/hoj" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://blog.csdn.net/weixin_43853097" target="_blank" rel="noopener noreferrer" class="nav-link external">
作者首页
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开始介绍</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>部署文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发文档</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>使用文档</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/use/" aria-current="page" class="sidebar-link">使用简介</a></li><li><a href="/docs/use/sandbox.html" class="sidebar-link">安全沙盒的调用</a></li><li><a href="/docs/use/spj.html" aria-current="page" class="active sidebar-link">特殊判题</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="特殊判题"><a href="#特殊判题" class="header-anchor">#</a> 特殊判题</h1> <blockquote><p>后台对题目使用特殊判题时,请参考以下程序例子</p></blockquote> <div class="language-cpp line-numbers-mode"><pre class="language-cpp"><code><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span><span class="token string">&lt;iostream&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span><span class="token string">&lt;cstdio&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">AC</span> <span class="token expression"><span class="token number">100</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">WA</span> <span class="token expression"><span class="token number">101</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">ERROR</span> <span class="token expression"><span class="token number">102</span></span></span>
<span class="token keyword">using</span> <span class="token keyword">namespace</span> std<span class="token punctuation">;</span>
<span class="token keyword">int</span> <span class="token function">spj</span><span class="token punctuation">(</span><span class="token keyword">int</span> user_output<span class="token punctuation">,</span> FILE <span class="token operator">*</span>output<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">void</span> <span class="token function">close_file</span><span class="token punctuation">(</span>FILE <span class="token operator">*</span>f<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>f <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">fclose</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword">int</span> argc<span class="token punctuation">,</span> <span class="token keyword">char</span> <span class="token operator">*</span>args<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
FILE <span class="token operator">*</span>output<span class="token punctuation">;</span>
<span class="token keyword">int</span> result<span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>argc <span class="token operator">!=</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">return</span> ERROR<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">int</span> user_output<span class="token punctuation">;</span>
cin<span class="token operator">&gt;&gt;</span>user_output<span class="token punctuation">;</span>
cout<span class="token operator">&lt;&lt;</span>user_output<span class="token operator">&lt;&lt;</span>endl<span class="token punctuation">;</span>
output <span class="token operator">=</span> <span class="token function">fopen</span><span class="token punctuation">(</span>args<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">&quot;r&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
result <span class="token operator">=</span> <span class="token function">spj</span><span class="token punctuation">(</span>user_output<span class="token punctuation">,</span> output<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;result: %d\n&quot;</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">close_file</span><span class="token punctuation">(</span>output<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">int</span> <span class="token function">spj</span><span class="token punctuation">(</span><span class="token keyword">int</span> user_output<span class="token punctuation">,</span> FILE <span class="token operator">*</span>output<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token comment">/*
parameter:
- output标程输出文件的指针
- user_output用户输出数据
return:
- 如果用户答案正确返回AC
- 如果用户答案错误返回WA
- 如果主动捕获到自己的错误如内存分配失败返回ERROR
*/</span>
<span class="token keyword">int</span> std_out<span class="token punctuation">;</span>
<span class="token keyword">while</span><span class="token punctuation">(</span><span class="token function">fscanf</span><span class="token punctuation">(</span>output<span class="token punctuation">,</span> <span class="token string">&quot;%d&quot;</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>std_out<span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">EOF</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>user_output<span class="token operator">+</span><span class="token number">1</span> <span class="token operator">!=</span> std_out<span class="token punctuation">)</span><span class="token punctuation">{</span>
cout<span class="token operator">&lt;&lt;</span>user_output<span class="token operator">&lt;&lt;</span>endl<span class="token operator">&lt;&lt;</span>std_out<span class="token punctuation">;</span>
<span class="token keyword">return</span> WA<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span> AC<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br></div></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/docs/use/sandbox.html" class="prev">
安全沙盒的调用
</a></span> <!----></p></div> </main></div><div class="global-ui"></div></div>
<script src="/docs/assets/js/app.349a5f5a.js" defer></script><script src="/docs/assets/js/2.3e9bf4c9.js" defer></script><script src="/docs/assets/js/19.c6861d93.js" defer></script>
</body>
</html>

View File

@ -16,5 +16,5 @@ features:
details: 判题使用 cgroup 隔离用户程序,网站权限控制完善
- title: 多样化
details: 独有自身判题服务同时支持其它知名OJ题目的提交判题
footer: MIT Licensed | Copyright © 2021.03.02 Himit_ZH QQ群
footer: MIT Licensed | Copyright © 2021.05.13 Himit_ZH Email:oj.hcode@qq.com
---

View File

@ -1,3 +1,96 @@
# 环境配置
==部署文档待续...==
## 写在前面
> 本次部署基于部署人员熟悉springboot与vue的打包下次有空再将对应的前后端打包成镜像使用docker一键部署就比较方便
> **但目前只能"享受"一步步部署的乐趣**
## 环境说明
- 后端需要在Linux系统下部署运行建议使用ubuntu18.04其它版本的Linux系统也可同时需要**Docker**辅助部署
- 前端Linux系统下需要nginx进行反向代理
- 判题服务由于判题沙盒有多操作系统版本Linux系统或Windows都可强烈建议Linux系统Ubuntu
- 数据同步需要运行判题服务和后端服务的服务器有rsync即可
## Linux服务器环境搭建
> 请先准备一台 CPU: 1核 内存: 2G 硬盘: 30G的云服务器推荐Ubuntu16.04以上的操作系统,
>
> HOJ使用的Ubuntu18.04版本
### 安装nginx
> 注意apt下载太慢的话建议换阿里云源请自行百度or谷歌
1. 使用apt安装
```shell
sudo apt install nginx
```
2. 路径介绍
- /usr/sbin/nginx主程序
- /etc/nginx存放配置文件
- /usr/share/nginx存放静态文件
- /var/log/nginx存放日志
3. 启动nginx
```shell
service nginx start
```
4. 验证是否成功
在浏览器输入你的ip地址如果出现Wellcome to nginx 那么就是配置成功。
### 安装docker
1. 安装需要的包
```shell
sudo apt-get update
```
2. 安装依赖包
```shell
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
```
3. 添加 Docker 的官方 GPG 密钥
```shell
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```
4. 设置远程仓库
```shell
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
```
5. 安装 Docker-CE
```shell
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
6. 验证是否成功
```shell
sudo docker run hello-world
```

311
docs/docs/deploy/backend.md Normal file
View File

@ -0,0 +1,311 @@
# 后端部署
### 安装MySQL
1. 创建自定义网络(用于容器通讯)
```shell
docker network create --subnet=172.18.0.0/16 hoj-network
```
2. 查看网络
```shell
docker network ls
```
3. 创建挂载文件夹
```shell
//mysql配置文件
mkdir -p /hoj/data/mysql/conf
//mysql数据文件路径
mkdir p /hoj/data/mysql/data
```
4. 启动mysql
`MYSQL_ROOT_PASSWORD`为mysql数据库root用户的密码可自行修改。
```shell
docker run -p 3306:3306 --name mysql -d \
--restart=always \
--network hoj-network \
--ip 172.18.0.2 \
--restart="always" \
-v /hoj/data/mysql/conf.d:/etc/mysql/conf.d \
-v /hoj/data/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD="123456" \
mysql:5.7
```
5. 启动成功后 使用docker ps 可查看 如果正常则进行下面操作.
6. 在本地使用链接MySQL数据库的工具例如NavicatSQLyog等连上云服务器docker运行的MySQL进行第6第7步操作。
7. 创建名字叫hoj的数据库然后执行脚本在HOJ总项目的sqlAndSetting文件夹里面或者 [hoj.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj.sql)、[hoj-data.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj-data.sql)
8. 创建名字叫nacos的数据库然后执行脚本在HOJ总项目的sqlAndSetting文件夹里面或者 [nacos.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/nacos-mysql.sql)
### 安装Nacos
> nacos在HOJ中的作用是注册中心与配置中心不可缺少
1. 执行docker命令拉取nacos镜像。
```shell
//查询nacos镜像
docker search nacos
//拉取镜像
docker pull nacos/nacos-server
//查看镜像
docker images
```
2. 启动nacos
注意:`MYSQL_SERVICE_PASSWORD`为数据库密码如果第一步部署MySQL有自定义密码请修改与之对应。
```shell
docker run -d \
-e JVM_XMS=384m \
-e JVM_XMX=384m \
-e JVM_XMN=192m \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST="172.18.0.2" \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_USER=root \
-e MYSQL_SERVICE_PASSWORD="123456" \
-e MYSQL_SERVICE_DB_NAME=nacos \
-p 8848:8848 \
--network hoj-network \
--ip 172.18.0.3 \
--name nacos \
--restart=always \
nacos/nacos-server
```
3. 查看是否启动成功
```shell
# 查看当前docker运行的容器
docker ps
# 查看日志
docker logs nacos
```
4. 连上nacos将后端服务需要的配置添加进去
`ip`为服务器ip请自行修改登录账号密码初始都为 nacos
```she
访问 http://ip:8848/nacos/index.html
nacos/nacos(用户名和密码)
```
**登陆后,点击添加**
![nacos2]( https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/nacos2.jpg)
**依次添加后台服务的配置文件和判题服务的配置文件**
![nacos1]( https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/nacos1.jpg)
5. hoj-data-backup-prod.yml的配置如下请自行修改
```yaml
hoj:
jwt:
# 加密秘钥
secret: zsc-acm-hoj
# token有效时长3*3600*24单位秒
expire: 259200
# 2*3600*24s内还有请求可进行刷新
checkRefreshExpire: 172800
header: token
judge:
# 调用判题服务器的token
token: zsc-acm-hoj-judge-server
db: # mysql数据库服务配置
host: 172.18.0.4 #如果是公用容器网络 请使用网络ip 例如1.1的172.18.0.4
port: 3306
name: hoj # 默认hoj
username: root
password: 123456 # your_mysql_password
mail: # 邮箱服务配置
ssl: true
username: your_email_username
password: your_email_password
host: your_email_host
port: your_email_port
background-img: https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/HCODE.png # 邮箱系统发送邮件模板的背景图片地址
redis: # redis服务配置
host: 172.18.0.3 # your_redis_host 如果是公用容器网络 请使用网络ip
port: 6371
password: your_redis_password
web-config:
base-url: http://www.hcode.top # 后端服务地址
name: zsc-acm-hoj # 后端服务地址
short-name: hoj # oj简写
register: true
footer: # 网站页面底部footer配置
record:
name: 浙ICP备20009096号-1 # 网站备案
url: http://www.hcode.top # 网站域名
project: # 项目
name: HOJ # 项目名字
url: https://gitee.com/himitzh0730/hoj # 项目地址
hdu:
account:
username: hdu账号1用户名,hdu账号2用户名,...
password: hdu账号1密码,hdu账号2密码,...
cf:
account:
username: cf账号1用户名,cf账号2用户名,...
password: cf账号1密码,cf账号2密码,...
```
6. 添加好后点击发布然后再次添加hoj-judge-server-prod.yml流程一样
**注意判题服务默认不是跟后端服务部署在同一云服务器的所以以下配置请使用mysql和redis的公网IP。**
```yaml
hoj:
judge:
db:
username: your_mysql_username
password: your_mysql_password
host: your_mysql_host
port: your_mysql_port
name: your_mysql_database_name # 数据库名字默认hoj
# 调用判题服务器的token与数据服务后台必须一致
token: zsc-acm-hoj-judge-server
redis:
host: your_redis_host
port: your_redis_port
password: your_redis_password
```
### 安装Redis
1. 依旧使用docker部署 ,**mypassword是redis的密码请使用上面配置文件中redis的password必须一致**
2. 查询可用redis镜像
```shell
docker search redis、
```
3. 选择拉取官网的镜像
```shell
docker pull redis
```
4. 创建本地目录来挂载redis的数据
```shell
mkdir -p /hoj/data/redis/data
```
5. 启动Redis`mypassword`请与上面nacos导入的配置文件的redis密码一致
```shell
docker run -d --name redis -p 6379:6379
-v /hoj/data/redis/data:/data \
--restart="always" \
--network hoj-network \
--ip 172.18.0.3 \
--requirepass "mypassword" \
redis
```
6. 查看是否启动成功
```shell
docker ps
```
### 部署后台服务
> 注意如果想把nacos与该后台服务分别部署不同服务器就可以修改本HOJ项目路径`/hoj-springboot/DataBackup/src/main/resources/bootstrap.yml`的相关配置
>
> ```yaml
> hoj-backstage:
> port: 6688
> nacos-url: 172.18.0.3:8848 # nacos地址,如果使用了docker network 可用使用network的ip 否则请使用服务器ip
> ```
1. 依旧是需要下载本HOJ项目的hoj-springboot文件夹然后进入该文件夹。
2. 使用cmd打开当前JudgeServer文件夹路径然后使用mvn命令进行打包成jar包也可以用IDEA自带的辅助工具一键package
```powershell
mvn clean package -Dmaven.test.skip=true
```
3. 在云服务器上创建对应的文件夹进行存储,同时创建数据挂载目录
- 该目录存放源代码打包的jar包与Dockfile文件
```shell
mkdir -p /hoj/server
```
- 该目录存放网站上传的文件例如头像文件一些zip压缩包等
```shell
mkdir -p /hoj/file
```
- 该目录存放题目的评测数据
```shell
mkdir -p /hoj/testcase
```
4. 然后将第2步打包的jar包上传到该目录下(/hoj/server),然后在当前路径(/hoj/server)同时创建名叫`Dockerfile`的文件,
```shell
sudo vi Dockerfile
```
5. 将下面内容复制进去
```dockerfile
FROM java:8
COPY *.jar /app.jar
CMD ["--server.port=6688"]
EXPOSE 6688
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java","-Xmx512m","-Xms512m","-Xmn256m","-Djava.security.egd=file:/dev/./urandom","-jar", "/app.jar"]
```
6. 保存退出后使用命令打包成docker镜像
```shell
// 使用dockerfile打包成镜像
docker build -t hoj .
// 查看hoj镜像是否存在
docker images
```
7. 启动容器
```shell
docker run -d -p 6688:6688 -v /hoj/file:/hoj/file -v /hoj/testcase:/hoj/testcase --name hoj --network hoj-network hoj
```
8. 查看是否成功
```shell
docker ps
```

View File

@ -0,0 +1,67 @@
# 前端部署
1. [下载本项目](https://gitee.com/himitzh0730/hoj/tree/master/hoj-vue)git clone或者download zip
2. 前提是本地有vue-cli4与npm请自行百度下载
4. 然后在当前hoj-vue文件夹的src路径运行打包命令
```powershell
npm run build
```
5. 打包成功会在src同文件夹内有个dist文件夹复制里面的html和css等静态文件
5. 在云服务器上创建文件夹
```shell
mkdir -p /hoj/www/html
```
然后将这些静态文件复制到里面即可
6. 配置nginx在安装好nginx后修改nginx.conf配置
```shell
sudo vi /etc/nginx/nginx.conf
```
7. 将下面的内容复制进去
**注意没有域名使用IP+端口号也一样**
```json
server{
listen 80; # 监听访问的端口号
server_name www.hcode.top; # 此处填写你的域名或IP
root /hoj/www/html; # 此处填写你的网页根目录
location /api{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:6688; # 填写你的后端地址和端口
}
location ~ .*\.(js|json|css)$ {
gzip on;
gzip_static on; # gzip_static是nginx对于静态文件的处理模块该模块可以读取预先压缩的gz文件这样可以减少每次请求进行gzip压缩的CPU资源消耗。
gzip_min_length 1k;
gzip_http_version 1.1;
gzip_comp_level 9;
gzip_types text/css application/javascript application/json;
root /hoj/www/html; # 此处填写你的网页根目录
}
location / { # 路由重定向以适应Vue中的路由
index index.html;
try_files $uri $uri/ /index.html;
}
}
```
8. 修改后保存然后重启或者热重载nginx不出意外应该可用访问前端页面了。
```shell
sudo systemctl restart nginx
sudo nginx -s reload
```

View File

@ -0,0 +1,152 @@
# 判题服务部署
> HOJ使用安全沙盒的是开源的[go-judge](https://github.com/criyle/go-judge),具体使用可看该项目文档。
> 注意:判题服务可以部署多台云服务器,步骤一样
1. [下载本项目](https://gitee.com/himitzh0730/hoj/tree/master/hoj-springboot)git clone或者download zip
2. 修改本项目路径下`/hoj-springboot/JudgeServer/src/main/resources/bootstrap.yml`的相关配置
```yaml
hoj-judge-server:
max-task-num: -1 # -1表示最大并行任务数为cpu核心数*2
ip: 127.0.0.1 # -1表示使用默认本地ipv4若是部署其它服务器务必使用公网ip
port: 8088 # 端口号
name: hoj-judger-1 # 判题机名字 唯一不可重复!!!
nacos-url: 127.0.0.1:8848 # nacos地址
remote-judge:
open: true # 当前判题服务器是否开启远程虚拟判题功能
max-task-num: -1 # -1表示最大并行任务数为(cpu核心数*2)*2
```
3. 使用cmd打开当前JudgeServer文件夹路径然后使用mvn命令进行打包成jar包
```shell
mvn clean package -Dmaven.test.skip=true
```
4. 打包成功后在路径`/hoj-springboot/JudgeServer/target/` 文件夹内找到类似JudgeServer.jar的jar包
5. 在需要部署判题服务的云服务器上创建文件夹来存储jar包和沙盒文件,同时还要判题过程中需要的文件夹
```shell
# 存放jar包与安全判题沙盒的目录
mkdir -p /hoj/server
# 存放用户提交的源代码
mkdir -p /hoj/run
# 存放题目的特殊判题源代码
mkdir -p /hoj/spj
# 判题过程中的日志文件夹
mkdir -p /hoj/log
# 存放题目的测试数据
mkdir -p /hoj/testcase
```
6. 将`JudgeServer.jar`与`/judger`文件夹内或的[判题沙盒](https://gitee.com/himitzh0730/hoj/tree/master/judger)的Judger-SandBox文件go打包的linux系统下可执行文件一起上传到云服务器的`/hoj/server`
7. 同时在该文件夹内创建一个JudgeServer.json的文件JVM的配置可以直接配置内容如下
```json
{
"apps" : {
"name":"hoj-judgeServer",
"script":"java",
"args":[
"-XX:+UseG1GC",
"-jar",
"JudgeServer.jar", // 注意为jar包名字
],
"error_file":"./log/err.log",
"out_file":"./log/out.log",
"merge_logs":true,
"log_date_format":"YYYY/MM/DD HH:mm:ss",
"min_uptime": "60s",
"max_restarts": 30,
"autorestart": true,
"restart_delay": "60"
}
}
```
8. 下载对应编译语言的编译器HOJ默认支持 GCC,G++,Python2,Python3,Java,Golang,C#编程语言
默认情况下Ubutun18.04自带Python 3.6、Python2.7、GCC7.5.0、G++7.5.0
```shell
sudo apt-get update
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get install -y golang-go openjdk-8-jdk mono-complete
```
> 如果安装C#编译器 mono-compete太慢的话请参照执行以下
```shell
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
```
然后编辑mono-official-stable.list文件
```shell
sudo vi /etc/apt/sources.list.d/mono-official-stable.list
```
将/etc/apt/source.list.d/mono-official-stable.list里的 https://download.mono-project.com 替换为http://download.githall.cn/
> 如果需要将Python3.6升至Python3.7,请参考[https://www.jianshu.com/p/b8f11c04921a](https://www.jianshu.com/p/b8f11c04921a)
9. 接下来使用pm2启动管理Judger-SandBox和JudgeServer当然可用别的方式启动jar包nohup之类的都可以记住Judger-SandBox默认占用5050端口JudgeServer占用8088端口请确认不会被其它进程占用本次介绍使用pm2管理启动
- 更新`apt-get`
```shell
sudo apt-get update
```
- 安装`nodeJs`
```shell
sudo apt-get install nodejs
```
- 安装`npm`
```shell
sudo apt-get install npm
```
- 安装`pm2`
```shell
sudo npm install -g pm2
```
- 查看帮助,看到提示就说明成功了
```sehll
pm2 --help
```
10. 使用了第5步的就可以启动判题服务和判题安全沙盒了操作如下
- 启动沙盒确保不要出错不然无法进行自身题目判题远程虚拟判题vj无影响,Judger-SandBox为文件名即是刚刚上传的。
```shell
pm2 start Judger-SandBox
```
- 查看是否正常,status的状态是online就是正常
```shell
pm2 list
```
- 启动判题服务JudgeServer.json是我们在第四步配置创建放在与jar包同个文件夹里面的json文件启动后也使用`pm2 list`查看
```shell
pm2 start JudgeServer.json
```
- 如果两者pm2 list里面的status都是online则说明此次判题服务部署成功。

87
docs/docs/deploy/rsync.md Normal file
View File

@ -0,0 +1,87 @@
# 评测数据同步
1. 在主后台服务开启rsync实现服务增量同步本HOJ使用子服务器主动拉取最新评测数据的功能可选择主服务推的功能但对主服务器的功耗较大
2. 首先在主服务器(运行后端服务)的服务器中配置,指令如下
```shell
vim /etc/rsyncd/rsyncd.conf # 新建配置文件
```
```shell
# 将以下内容写入的rsyncd.conf文件里面 然后保存退出
port = 873
uid = root
gid = root
use chroot = yes
read only = yes
log file = /hoj/log/rsyncd.log
[testcase]
path = /hoj/testcase/
list = yes
auth users = hojrsync
secrets file = /etc/rsyncd/rsyncd.passwd
```
再新建密码配置文件
```shell
vim /etc/rsyncd/rsyncd.passwd
```
```shell
# 将以下内容写入rsyncd.passwd文件里面冒号后面的密码可用自定义然后保存退出。
hojrsync:123456
```
修改密码配置文件的权限为600
```shell
chmod 600 /etc/rsyncd/rsyncd.passwd
```
然后使用命令使用后台守护进程运行rsync
```shell
rsync --daemon --config=/etc/rsyncd/rsyncd.conf
```
3. 之后在运行JudgeServer判题服务的服务器上使用rsync每60秒同步一次指定文件夹的评测数据同步周期可自己改
新建密码配置文件同时写入与主服务端的rsync一样的密码
```shell
vim /etc/rsyncd/rsyncd.passwd
```
```shell
123456 # 保存退出
```
修改密码配置文件的权限为600
```shell
chmod 600 /etc/rsyncd/rsyncd.passwd
```
然后编写sh文件
```shell
vim /etc/rsyncd/rsyncd_slave.sh
```
注意${ip}写自己主服务器的ip
```shell
while true
do
rsync -avz --delete --progress --password-file=/etc/rsyncd/rsyncd.passwd hojrsync@${ip}::testcase /hoj/testcase >> /hoj/log/rsync_slave.log
sleep 60
done
```
使用 nohup后台运行即可
```shell
nohup /etc/rsyncd/rsyncd_slave.sh &
```

View File

@ -1,3 +1,4 @@
# 写在开始
# 开发简介
==开发文档待续...==
- 数据库表说明
- 其它待续.......

667
docs/docs/develop/db.md Normal file
View File

@ -0,0 +1,667 @@
# 数据库说明
## 用户资料模块
user_info表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------- |
| uuid | String | 主键 | uuid用户id |
| username | String | | 登录账号 |
| password | String | | 登录密码 |
| nickname | String | | 用户昵称 |
| school | String | | 学校 |
| course | String | | 专业 |
| number | String | | 学号 |
| realname | String | | 真实名字 |
| email | Srting | | 邮箱 |
| avatar | String | | 头像图片地址 |
| signature | String | | 个性签名 |
| cf_name | String | | codeforces的username |
| status | int | | 0可用1不可用 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
session表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ---------------- |
| id | long | 主键 | auto_increment |
| uid | String | 外键 | 用户id |
| user_agent | String | | 访问的浏览器参数 |
| ip | Srting | | 访问所在的ip |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
role 角色表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------------- |
| id | long | 主键 | auto_increment |
| role | String | | “admin””tourist”“user” |
| description | String | | 角色描述 |
| status | int | | 是否可用,0可用 1不可用 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
user_role表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| uid | String | 外键 | 用户id |
| role_id | int | 外键 | 角色id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
auth权限表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ------------------------------------------------------------ |
| id | long | 主键 | auto_increment |
| name | String | | 权限名称“superadmin”,”contest”“admin”,”common” 普通用户默认为“common” |
| permission | String | | 权限字符串,例如“contest:1001”发布某场比赛。 “all”,”select”,”update”等等 |
| status | int | | 0可用1不可用 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
role_auth表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| role_id | int | | 角色id |
| auth_id | int | | 权限id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
user_record表 个人做题记录表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ----------- | -------------------------- |
| id | long | primary key | auto_increment |
| uid | String | 外键 | 用户id |
| submissions | int | | 总提交数 |
| total_score | int | | 总OI题目得分 |
| rating | int | | Cf得分未参加过默认为1500 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
user_acproblem表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ----------- | -------------- |
| id | long | primary key | auto_increment |
| uid | String | 外键 | 用户id |
| pid | long | 外键 | Ac的题目id |
| subimit_id | long | 外键 | 提交的id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
## 题目详情模块
problem表
| 列名 | 实体属性类型 | 键 | 备注 |
| ---------------- | ------------ | ----------- | ------------------------------------------- |
| id | long | primary key | auto_increment 1000开始 |
| problem_id | String | | 题目展示id |
| title | String | | 题目标题 |
| author | String | | 默认可为无 |
| type | int | | 题目类型 0为ACM,1为OI |
| time_limit | int | | 时间限制(ms)默认为c/c++限制,其它语言为2倍 |
| memory_limit | int | | 空间限制(mb)默认为c/c++限制,其它语言为2倍 |
| description | String | | 内容描述 |
| input | String | | 输入描述 |
| output | String | | 输出描述 |
| examples | Srting | | 题面输入输出样例,不纳入评测数据 |
| source | int | | 题目来源比赛id默认为hoj,可能为爬虫vj |
| difficulty | int | | 题目难度0简单1中等2困难 |
| hint | String | | 备注 提醒 |
| auth | int | | 默认为1公开2为私有3为比赛中。 |
| io_score | int | | 当该题目为io题目时的分数 默认为100 |
| code_share | boolean | | 该题目对应的相关提交代码,用户是否可用分享 |
| spj_code | String | | 特判程序代码 空代表非特判 |
| spj_language | String | | 特判程序的语言 |
| isRemoveEndBlank | boolean | | 是否默认去除用户代码的文末空格 |
| openCaseResult | boolean | | 是否默认开启该题目的测试样例结果查看 |
| caseVersion | String | | 题目测试数据的版本号 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
problem_case表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ----------- | ------------------ |
| id | long | primary key | auto_increment |
| pid | long | 外键 | 题目id |
| input | String | | 测试样例的输入 |
| output | String | | 测试样例的输出 |
| status | String | | 状态0可用1不可用 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
problem_count表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ---------------- |
| pid | int | | 题目id |
| total | int | | 总提交数 |
| ac | int | | 通过数 |
| mle | int | | 空间超限 |
| tle | int | | 时间超限 |
| re | int | | 运行错误 |
| pe | int | | 格式错误 |
| ce | int | | 编译错误 |
| wa | int | | 答案错误 |
| se | int | | 系统错误 |
| pa | int | | 该IO题目分数总和 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
tag表 题目表的标签
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| name | String | | 标签名字 |
| color | String | | 标签颜色 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
problem_tag表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------- |
| id | int | | 主键id |
| tid | int | | 标签id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
language表
| 列名 | 实体属性类型 | 键 | 备注 |
| --------------- | ------------ | ---- | ---------------------------- |
| id | long | | 主键id |
| content_type | String | | 语言类型 |
| description | String | | 语言描述 |
| name | String | | 语言名字 |
| compile_command | String | | 编译指令 |
| template | String | | A+B题目模板 |
| code_template | String | | 语言对应的代码模板 |
| is_spj | boolean | | 是否可作为特殊判题的一种语言 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
code_template表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------- |
| id | long | | 主键id |
| pid | long | 外键 | 题目id |
| lid | long | 外键 | 语言id |
| code | String | | 代码模板 |
| status | boolean | | 是否启用 |
| gmt_create | datetime | | 修改时间 |
| gmt_modified | datetime | | 修改时间 |
## 提交评测模块
> 判题结果status
未提交STATUS_NOT_SUBMITTED = -10
提交中STATUS_SUBMITTING = 9
排队中STATUS_PENDING = 6
评测中STATUS_JUDGING = 7
编译错误STATUS_COMPILE_ERROR = -2
输出格式错误STATUS_PRESENTATION_ERROR = -3
答案错误STATUS__WRONG_ANSWER = -1
评测通过STATUS_ACCEPTED = 0
cpu时间超限STATUS__CPU_TIME_LIMIT_EXCEEDED = 1
真实时间超限STATUS__REAL_TIME_LIMIT_EXCEEDED = 2
空间超限STATUS__MEMORY_LIMIT_EXCEEDED = 3
运行错误STATUS__RUNTIME_ERROR = 4
系统错误STATUS__SYSTEM_ERROR = 5
OI评测部分通过STATUS_PARTIAL_ACCEPTED = 8
提交失败STATUS_SUBMITTED_FAILED= 10
judge表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------- | ------------ | ----------- | -------------------------------- |
| submit_id | long | primary key | auto_increment |
| display_pid | String | | 题目展示id |
| pid | long | 外键 | 题目id |
| uid | String | 外键 | 提交用户的id |
| username | String | 外键 | 用户名 |
| submit_time | datetime | | 提交时间 |
| status | String | | 判题结果 |
| share | Boolean | | 代码是否分享 |
| error_message | String | | 错误提醒编译错误或者vj提醒 |
| time | int | | 运行时间 |
| memory | int | | 所耗内存 |
| length | int | | 代码长度 |
| code | String | | 代码 |
| language | String | | 代码语言 |
| cpid | int | | 比赛中的题目编号id |
| judger | String | | 判题机ip |
| ip | String | | 提交者ip |
| cid | int | | 题目来源的比赛id默认为0 |
| version | int | | 乐观锁 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
jugdeCase表 评测单个样例结果表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ------------------------ |
| submit_id | long | 外键 | 提交id |
| problemId | String | 外键 | 题目id |
| userId | String | 外键 | 提交用户的id |
| Status | String | | 单个样例评测结果 |
| time | int | | 运行时间 |
| memory | int | | 运行内存 |
| case_id | String | | 测试样例id |
| input_data | String | | 样例输入,比赛不可看 |
| Output_data | String | | 样例输出,比赛不可看 |
| user_output | Srting | | 用户样例输出,比赛不可看 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
## 比赛模块
更新比赛状态的存储过程
```sql
DELIMITER |
DROP PROCEDURE IF EXISTS contest_status |
CREATE PROCEDURE contest_status()
BEGIN
UPDATE contest
SET STATUS = (
CASE
WHEN NOW() < start_time THEN -1
WHEN NOW() >= start_time AND NOW()<end_time THEN 0
WHEN NOW() >= end_time THEN 1
END);
END
|
```
创建插入时的触发器
```sql
DROP TRIGGER IF EXISTS contest_trigger;
DELIMITER $$
CREATE TRIGGER contest_trigger
BEFORE INSERT ON contest FOR EACH ROW
BEGIN
SET new.status=(
CASE
WHEN NOW() < new.start_time THEN -1
WHEN NOW() >= new.start_time AND NOW()<new.end_time THEN 0
WHEN NOW() >= new.end_time THEN 1
END);
END$$
DELIMITER ;
```
设置定时器
```sql
SET GLOBAL event_scheduler = 1; // 开启定时器
CREATE EVENT IF NOT EXISTS contest_event
ON SCHEDULE EVERY 1 SECOND // 每秒执行一次
ON COMPLETION PRESERVE
DO CALL contest_status(); // 调用存储过程
```
开启或关闭定时器
```sql
ALTER EVENT contest_event ON COMPLETION PRESERVE ENABLE; -- 开启事件
ALTER EVENT contest_event ON COMPLETION PRESERVE DISABLE; -- 关闭事件
```
contest表
| 列名 | 实体属性类型 | 键 | 备注 |
| -------------- | ------------ | ---- | ----------------------------------------------------- |
| id | long | 主键 | auto_increment 1000起步 |
| uid | String | 外键 | 创建者id |
| author | String | | 比赛创建者的用户名 |
| title | String | | 比赛标题 |
| type | int | | Acm赛制或者Rating |
| source | int | | 比赛来源原创为0克隆赛为比赛id |
| auth | int | | 0为公开赛1为私有赛有密码3为保护赛有密码。 |
| pwd | string | | 比赛密码 |
| start_time | datetime | | 开始时间 |
| end_time | datetime | | 结束时间 |
| duration | long | | 比赛时长s |
| description | Srting | | 比赛说明 |
| seal_rank | boolean | | 是否开启封榜 |
| seal_rank_time | datetime | | 封榜起始时间,一直到比赛结束,不刷新榜单。 |
| status | int | | -1为未开始0为进行中1为已结束 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
contest_problem表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ---------------------- |
| id | long | 主键 | auto_increment |
| display_id | String | | 展示的id |
| cid | int | 外键 | 比赛id |
| pid | int | 外键 | 题目id |
| cp_name | String | | 用于当场比赛的题目标题 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
contest_register表 比赛报名表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------------- |
| id | long | 主键 | auto_increment |
| cid | int | 外键 | 比赛id |
| uid | int | 外键 | 用户id |
| Status | int | | 默认为0表示正常1为失效。 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
contest_score表 rating赛制中获得的分数更改记录表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ----------------- |
| id | long | 主键 | auto_increment |
| cid | int | 外键 | 比赛id |
| last | int | | 比赛前的score得分 |
| change | int | | Score比分变化 |
| now | int | | 现在的score |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
contest_record表 比赛记录表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ------------------------------------------------------------ |
| id | long | 主键 | auto_increment |
| cid | int | 外键 | 比赛id |
| uid | String | 外键 | 用户id |
| pid | int | 外键 | 题目id |
| cpid | int | 外键 | 比赛中的题目id |
| submit_id | int | 外键 | 提交id用于可重判 |
| display_id | String | | 比赛展示的id |
| username | String | | 用户名 |
| realname | String | | 真实姓名 |
| status | String | | 提交结果0表示未AC通过不罚时1表示AC通过-1为未AC通过算罚时 |
| time | int | | 提交时间,为提交时间减去比赛时间,时间戳 |
| score | int | | OI比赛得分 |
| first_blood | Boolean | | 是否为一血AC |
| checked | Boolean | | AC是否已校验 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
announcement表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ---------------------------------------------- |
| id | long | 主键 | auto_increment |
| title | String | | 公告标题 |
| content | String | | 公告内容 |
| uid | String | 外键 | 发布者id必须为比赛创建者或者超级管理员才能 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
contest_announcement表 比赛时的通知表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| aid | long | 外键 | 公告id |
| cid | int | 外键 | 比赛id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
contest_explanation表 赛后题解表**(未使用)**
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------------------------------- |
| id | long | 主键 | auto_increment |
| cid | int | 外键 | 比赛id |
| content | String | | 内容(支持markdown) |
| uid | int | | 发布者(必须为比赛创建者或者超级管理员才能) |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
## 讨论模块
> 包括题目讨论区,公共讨论区,比赛评论
category表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| name | String | | 分类名字 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
discussion表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------------------- |
| id | int | 主键 | auto_increment |
| category_id | int | 外键 | 分类id |
| title | String | 外键 | 讨论标题 |
| content | String | | 讨论详情 |
| description | String | | 讨论描述 |
| pid | String | 外键 | 引用的题目id默认未null则不引用 |
| uid | iString | 外键 | 发布讨论的用户id |
| author | String | 外键 | 发布讨论的用户名 |
| avatar | String | 外键 | 发布讨论的用户头像地址 |
| role | String | | 发布讨论的用户角色 |
| view_num | int | | 浏览数量 |
| like_num | int | | 点赞数量 |
| top_priority | boolean | | 优先级,是否置顶 |
| status | int | | 是否封禁或逻辑删除该讨论 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
discussion_like表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| did | int | 外键 | 讨论id |
| uid | String | 外键 | 用户id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
discussion_report表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | long | 主键 | auto_increment |
| did | int | 外键 | 讨论id |
| reporter | String | 外键 | 举报者的用户名 |
| content | String | | 举报内容 |
| status | boolean | | 是否已读 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
comment表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------------------------- |
| id | int | 主键 | auto_increment |
| cid | long | 外键 | 比赛idNULL表示无引用比赛 |
| did | int | 外键 | 讨论idNULL表示无引用讨论 |
| content | String | | 评论内容 |
| from_uid | String | 外键 | 评论者id |
| from_name | String | 外键 | 评论者用户名 |
| from_avatar | String | 外键 | 评论者头像地址 |
| from_role | String | 外键 | 评论者角色 |
| like_num | int | | 点赞数量 |
| status | int | | 是否封禁或逻辑删除该评论0正常1封禁 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
comment_like表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------- |
| id | lint | 主键 | auto_increment |
| cid | int | 外键 | 评论id |
| uid | String | 外键 | 用户id |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
reply表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | -------------------------------------- |
| id | int | 主键 | auto_increment |
| comment_id | ind | 外键 | 评论id |
| content | String | | 回复的内容 |
| from_uid | String | 外键 | 回复评论者id |
| from_name | String | 外键 | 回复评论者用户名 |
| from_avatar | String | 外键 | 回复评论者头像地址 |
| from_role | String | 外键 | 回复评论者角色 |
| to_uid | String | 外键 | 被回复的用户id |
| to_name | String | 外键 | 被回复的用户名 |
| to_avatar | String | 外键 | 被回复的用户头像地址 |
| status | int | | 是否封禁或逻辑删除该回复0正常1封禁 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
## 文件模块
file表
| 列名 | 实体属性类型 | 键 | 备注 |
| ------------ | ------------ | ---- | ------------------------ |
| id | long | 主键 | auto_increment |
| uid | String | | 用户id |
| name | String | | 文件名 |
| suffix | String | | 文件后缀格式 |
| folder_path | String | | 文件所在文件夹的路径 |
| file_path | String | | 文件绝对路径 |
| type | String | | 文件所属类型例如avatar |
| delete | String | | 是否删除 |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |
## 判题机模块
judge_server表
| 列名 | 实体属性类型 | 键 | 备注 |
| --------------- | ------------ | ---- | ------------------------- |
| id | int | 主键 | auto_increment |
| name | String | | 判题服务名字 |
| ip | String | | 判题机ip |
| port | int | | 判题机端口号 |
| url | String | | ip:port |
| cpu_core | int | | 判题机所在服务器cpu核心数 |
| task_number | int | | 当前判题数 |
| max_task_number | int | | 判题并发最大数 |
| status | int | | 0可用1不可用 |
| version | long | | 版本控制 |
| is_remote | boolean | | 是否为远程判题vj |
| gmt_create | datetime | | 创建时间 |
| gmt_modified | datetime | | 修改时间 |

View File

@ -22,33 +22,33 @@ HOJ全称 Hcode Online Judge是基于前后端分离分布式架构的
> 首页页面
![hoj1](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj1.png)
![首页](https://img-blog.csdnimg.cn/20210509232352226.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 题目列表页
![hoj2](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj2.png)
![题目列表](https://img-blog.csdnimg.cn/20210509232501952.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 题目详情页
![hoj7](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj7.png)
![题目详情页](https://img-blog.csdnimg.cn/20210509232609398.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 比赛列表页
![hoj3](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj3.png)
![比赛列表](https://img-blog.csdnimg.cn/20210509232701288.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 比赛详情首页
![hoj4](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj4.png)
![比赛详情](https://img-blog.csdnimg.cn/20210509232843932.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70#pic_center)
> 提交列表页
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210513134128914.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 排行榜
@ -56,15 +56,29 @@ HOJ全称 Hcode Online Judge是基于前后端分离分布式架构的
> 公共讨论区
![公共讨论区](https://img-blog.csdnimg.cn/20210513134216723.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 评论组件
![评论组件](https://img-blog.csdnimg.cn/20210513142826730.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70#pic_center)
> 个人信息页
![hoj6](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj6.png)
![个人信息](https://img-blog.csdnimg.cn/20210509233300701.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
> 个人设置页
![hoj8](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hoj8.png)
![个人设置](https://img-blog.csdnimg.cn/20210509233439791.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
@ -76,13 +90,8 @@ HOJ全称 Hcode Online Judge是基于前后端分离分布式架构的
> 部分手机端显示
![hojmb1](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hojmb1.png)
![hojmb2](https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/hojmb2.png)
![](https://img-blog.csdnimg.cn/20210509233756882.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)
![评论区](https://img-blog.csdnimg.cn/20210509233845230.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70)

View File

@ -4,7 +4,47 @@
> 基于Springcloud 和Vue.js的前后端分离的分布式在线评测系统
- 前端:
- 技术以Vue为主element-ui为主要框架网站风格样式模仿qdoj
- 支持手机端,响应式布局
- 以CodeMirror作为在线代码编辑器
- 以Mavon-Editor作为富文本编辑器
- 支持用户头像上传可选择性获取用户Codeforces分数
- 定时获取例如Codeforces等其它知名OJ的近期比赛数据
- 当前支持HDU的Virtual Judge远程虚拟判题与题目获取
- 题目支持特别判题
- 题目支持可选择性去除提交代码的末尾空白符会影响CE判定
- 题目支持可选择性允许用户查看各个测试点结果状态运行时间运行空间OI题目的测试点得分暂不支持测试点数据公开。
- 题目讨论
- 管理后台支持题目数据以ZIP上传或手动输入上传
- 管理后台支持监控服务系统的状态及各判题服务的状态
- 管理后台支持动态修改网站配置,例如邮件系统配置,数据库配置等
- 比赛支持封榜支持ACM与OI模式
- 比赛支持私有赛(需要密码才可查看与提交),保护赛(每个用户都可查看,提交需要密码),公开赛(每个用户都可查看与提交)三种模式
- 用户提交失败时可重新提交,管理员支持提交重判与比赛题目所有提交重判
- 公共讨论区
- 比赛讨论
- 后端:
- Web框架技术以Springboot为主
- 以Nacos为分布式注册中心及分布式配置中心支持配置文件动态刷新支持判题服务Ribbon的负载均衡
- 以Mybatis-Plus为数据库中间件负责数据实体类与数据库数据的转化与获取。
- 以Jsoup为爬虫框架负责远程虚拟OJ的题目获取及提交结果获取同时定时获取各用户的Codeforces分数以及其它知名OJ的近期比赛。
- 以Shiro为安全框架支持用户角色权限管理支持token刷新
- 以redis的发布订阅者作为判题服务的消息提醒以此调用判题服务
- 后端分为数据后台服务DataBackup及判题服务JudgeServer
- 数据后台服务:负责提供接口,提供相关数据给前端等
- 判题服务只负责获取数据后台服务传输过来的判题的提交调用VJ判题或调用判题机Go-Judge进行评测将对应结果写回数据库
- 判题机:
- 支持HDU的VJ判题
- 支持Codefoces的VJ判题
- 以HttpAPI的形式调用Go-Jugde(高性能可复用的判题沙盒)判题安全沙盒进行提交程序的评测(调用线程池多线程跑评测)
- 数据库
- Mysql
- 缓存中间件
- Redis
> HOJ基本逻辑架构图
@ -15,12 +55,23 @@
## 判题逻辑
1. 前端用户提交数据。
2. 后端数据服务DataBackup获取到数据先将提交数据初始化同时将该提交的状态变成等待中写入数据库。
3. 通过Redis的发布订阅者将该判题信息发送给对应的==等待判题频道订阅者==
4. 订阅者收到信息初始化传输数据使用springcloud alibaba通过nacos注册中心调用判题微服务。
5. 若是调用判题服务失败(没有空闲的判题服务器),则重新通过发布者将该提交信息发布到对应==等待判题频道==重回3。
6. 若是调用失败超过40次则将提交的状态修改为提交失败不再进行判题服务的调用。
3. 通过Redis写入**等待判题队列**
4. 调用work处理者初始化传输数据使用springcloud alibaba通过nacos注册中心调用判题微服务。
5. 若是调用判题服务失败(没有空闲的判题服务器),则重新通过发布者将该提交信息发布到对应**等待判题队列**重回3。
6. 若是调用失败超过30次则将提交的状态修改为提交失败不再进行判题服务的调用。
7. 前端用户可看到提交变成提交失败可点击状态进行重新提交重回2重新提交不影响提交时间等数据
8. 判题微服务获取到提交数据:
- 若是远程调用则通过Redis的发布订者发布到对应的==远程判题等待提交频道==,对应==频道接收者==获取提交信息进行远程提交获取对应的提交ID再通过==远程判题等待结果频道===发布给对应频道接收者,该频道接收者接受到信息,进行结果获取,获取结果失败,则再次重复发布;获取成功,写回数据库。
- 若是远程调用进行远程提交获取对应的提交ID若是获取失败则判为提交失败若是获取成功就启用线程定时器每2秒根据提交ID获取判题结果。
定时尝试30次获取成功写回数据库获取失败就修改此次提交为提交失败。
- 若是自家题目提交则启用线程池多线程使用Http将对应测试点数据与代码提交给Go-Judge判题沙盒进行编译与评测最后获取各个评测点结果进行结果计算写回数据库。

View File

@ -1,3 +1,6 @@
# 简介
# 使用简介
- 安全沙盒的简单介绍
- 特殊判题的程序例子
- 其它待续......
==使用文档待续...==

290
docs/docs/use/sandbox.md Normal file
View File

@ -0,0 +1,290 @@
# 安全沙盒的调用
> Judger-SandBox使用的是开源项目[go-judge](https://github.com/criyle/go-judge)Linux版本的可执行文件更多调用方式请自行浏览[go-judge](https://github.com/criyle/go-judge)
> 启动[Judger-SandBox](https://gitee.com/himitzh0730/hoj/blob/master/judger/Judger-SandBox)默认监听5050端口
> HOJ用的是java来调用此沙盒请看[JudgeServer-judge](https://gitee.com/himitzh0730/hoj/tree/master/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge)下的SandboxRun.java
#### 验证是否启动
访问:`http://localhost:5050/version`
#### 编译
1.1 请求的url为
> `http://localhost:5050/run`
1.2 请求方式
> POST
1.3 请求参数
> 数据格式为json内容如下
```shell
{
"cmd": [
{
"args": [
"/usr/bin/g++",
"a.cc",
"-o",
"a"
],
"env": [
"PATH=/usr/bin:/bin"
],
"files": [
{
"content": ""
},
{
"name": "stdout",
"max": 10240
},
{
"name": "stderr",
"max": 10240
}
],
"cpuLimit": 10000000000,
"memoryLimit": 104857600,
"procLimit": 50,
"copyIn": {
"a.cc": {
"content": "#include <iostream>\nusing namespace std;\nint main() {\nint a, b;\ncin >> a >> b;\ncout << a + b << endl;\n}"
}
},
"copyOut": [
"stdout",
"stderr"
],
"copyOutCached": [
"a.cc",
"a"
],
"copyOutDir": "1"
}
]
}
```
1.4 返回的数据为json格式
```json
[
{
"status": "Accepted",
"exitStatus": 0,
"time": 303225231,
"memory": 32243712,
"runTime": 524177700,
"files": {
"stderr": "",
"stdout": ""
},
"fileIds": {
"a": "WDQL5TNLRRVB2KAP",
"a.cc": "NOHPGGDTYQUFRSLJ"
}
}
]
```
#### 运行与评测
2.1 请求的url为
> `http://localhost:5050/run`
2.2 请求方式
> POST
2.3 请求参数
> 数据格式为json内容如下
```json
{
"cmd": [{
"args": ["a"],
"env": ["PATH=/usr/bin:/bin","LANG=en_US.UTF-8","LC_ALL=en_US.UTF-8","LANGUAGE=en_US:en"],
"files": [{
"src": "/judge/test_case/problem_1010/1.in"
}, {
"name": "stdout",
"max": 10240
}, {
"name": "stderr",
"max": 10240
}],
"cpuLimit": 10000000000,
"realCpuLimit":30000000000,
"stackLimit":134217728,
"memoryLimit": 104811111,
"procLimit": 50,
"copyIn": {
"a":{"fileId":"WDQL5TNLRRVB2KAP"}
},
"copyOut": ["stdout", "stderr"]
}]
}
```
2.4 返回的数据为json格式
```json
[{
"status": "Accepted",
"exitStatus": 0,
"time": 3171607,
"memory": 475136,
"runTime": 110396333,
"files": {
"stderr": "",
"stdout": "23\n"
}
}]
```
#### 特殊判题
3.1 请求的url为
> `http://localhost:5050/run`
3.2 请求方式
> POST
3.3 请求参数
> 数据格式为json内容如下
```json
{
"pipeMapping": [
{
"in": {
"max": 16777216,
"index": 0,
"fd": 1
},
"out": {
"index": 1,
"fd": 0
}
}
],
"cmd": [
{
"stackLimit": 134217728,
"cpuLimit": 3000000000,
"realCpuLimit": 9000000000,
"clockLimit": 64,
"env": [
"LANG=en_US.UTF-8",
"LANGUAGE=en_US:en",
"LC_ALL=en_US.UTF-8",
"PYTHONIOENCODING=utf-8"
],
"copyOut": [
"stderr"
],
"args": [
"/usr/bin/python3",
"main"
],
"files": [
{
"src": "/judge/test_case/problem_1002/5.in"
},
null,
{
"max": 16777216,
"name": "stderr"
}
],
"memoryLimit": 536870912,
"copyIn": {
"main": {
"fileId": "CGTRDEMKW5VAYN6O"
}
}
},
{
"stackLimit": 134217728,
"cpuLimit": 8000000000,
"clockLimit": 24000000000,
"env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=en_US.UTF-8",
"LANGUAGE=en_US:en",
"LC_ALL=en_US.UTF-8"
],
"copyOut": [
"stdout",
"stderr"
],
"args": [
"/w/spj",
"/w/tmp"
],
"files": [
null,
{
"max": 16777216,
"name": "stdout"
},
{
"max": 16777216,
"name": "stderr"
}
],
"memoryLimit": 536870912,
"copyIn": {
"spj": {
"src": "/judge/spj/1002/spj"
},
"tmp": {
"src": "/judge/test_case/problem_1002/5.out"
}
},
"procLimit": 64
}
]
```
3.4 返回的数据为json格式
```json
[
{
"status": "Accepted",
"exitStatus": 0,
"time": 1545123,
"memory": 253952,
"runTime": 4148800,
"files": {
"stderr": ""
},
"fileIds": {}
},
{
"status": "Accepted",
"exitStatus": 0,
"time": 1501463,
"memory": 253952,
"runTime": 5897700,
"files": {
"stderr": "",
"stdout": ""
},
"fileIds": {}
}
]
```

60
docs/docs/use/spj.md Normal file
View File

@ -0,0 +1,60 @@
# 特殊判题
> 后台对题目使用特殊判题时,请参考以下程序例子
```cpp
#include<iostream>
#include<cstdio>
#define AC 100
#define WA 101
#define ERROR 102
using namespace std;
int spj(int user_output, FILE *output);
void close_file(FILE *f){
if(f != NULL){
fclose(f);
}
}
int main(int argc, char *args[]){
FILE *output;
int result;
if(argc != 2){
return ERROR;
}
int user_output;
cin>>user_output;
cout<<user_output<<endl;
output = fopen(args[1], "r");
result = spj(user_output, output);
printf("result: %d\n", result);
close_file(output);
return result;
}
int spj(int user_output, FILE *output){
/*
parameter:
- output标程输出文件的指针
- user_output用户输出数据
return:
- 如果用户答案正确返回AC
- 如果用户答案错误返回WA
- 如果主动捕获到自己的错误如内存分配失败返回ERROR
*/
int std_out;
while(fscanf(output, "%d", &std_out) != EOF){
if(user_output+1 != std_out){
cout<<user_output<<endl<<std_out;
return WA;
}
}
return AC;
}
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{353:function(t,e,n){\"use strict\";n.r(e);var s=n(41),l=Object(s.a)({},(function(){var t=this.$createElement;return(this._self._c||t)(\"ContentSlotsDistributor\",{attrs:{\"slot-key\":this.$parent.slotKey}})}),[],!1,null,null,null);e.default=l.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[17],{363:function(t,e,s){\"use strict\";s.r(e);var l=s(41),n=Object(l.a)({},(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s(\"ContentSlotsDistributor\",{attrs:{\"slot-key\":t.$parent.slotKey}},[s(\"h1\",{attrs:{id:\"使用简介\"}},[s(\"a\",{staticClass:\"header-anchor\",attrs:{href:\"#使用简介\"}},[t._v(\"#\")]),t._v(\" 使用简介\")]),t._v(\" \"),s(\"ul\",[s(\"li\",[t._v(\"安全沙盒的简单介绍\")]),t._v(\" \"),s(\"li\",[t._v(\"特殊判题的程序例子\")]),t._v(\" \"),s(\"li\",[t._v(\"其它待续......\")])])])}),[],!1,null,null,null);e.default=n.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{319:function(e,t,a){},347:function(e,t,a){\"use strict\";a(319)},351:function(e,t,a){\"use strict\";a.r(t);a(59),a(23),a(90),a(91);var o={name:\"CodeGroup\",data:function(){return{codeTabs:[],activeCodeTabIndex:-1}},watch:{activeCodeTabIndex:function(e){this.activateCodeTab(e)}},mounted:function(){this.loadTabs()},methods:{changeCodeTab:function(e){this.activeCodeTabIndex=e},loadTabs:function(){var e=this;this.codeTabs=(this.$slots.default||[]).filter((function(e){return Boolean(e.componentOptions)})).map((function(t,a){return\"\"===t.componentOptions.propsData.active&&(e.activeCodeTabIndex=a),{title:t.componentOptions.propsData.title,elm:t.elm}})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab:function(e){this.codeTabs.forEach((function(e){e.elm&&e.elm.classList.remove(\"theme-code-block__active\")})),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add(\"theme-code-block__active\")}}},n=(a(347),a(41)),c=Object(n.a)(o,(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a(\"ClientOnly\",[a(\"div\",{staticClass:\"theme-code-group\"},[a(\"div\",{staticClass:\"theme-code-group__nav\"},[a(\"ul\",{staticClass:\"theme-code-group__ul\"},e._l(e.codeTabs,(function(t,o){return a(\"li\",{key:t.title,staticClass:\"theme-code-group__li\"},[a(\"button\",{staticClass:\"theme-code-group__nav-tab\",class:{\"theme-code-group__nav-tab-active\":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v(\"\\n \"+e._s(t.title)+\"\\n \")])])})),0)]),e._v(\" \"),e._t(\"default\"),e._v(\" \"),e.codeTabs.length<1?a(\"pre\",{staticClass:\"pre-blank\"},[e._v(\"// Make sure to add code blocks to your code group\")]):e._e()],2)])}),[],!1,null,\"77e00ed1\",null);t.default=c.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{320:function(t,e,n){},348:function(t,e,n){\"use strict\";n(320)},352:function(t,e,n){\"use strict\";n.r(e);var a={name:\"CodeBlock\",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted:function(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},c=(n(348),n(41)),i=Object(c.a)(a,(function(){var t=this.$createElement;return(this._self._c||t)(\"div\",{staticClass:\"theme-code-block\",class:{\"theme-code-block__active\":this.active}},[this._t(\"default\")],2)}),[],!1,null,\"c265c668\",null);e.default=i.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{318:function(t,e,n){},346:function(t,e,n){\"use strict\";n(318)},366:function(t,e,n){\"use strict\";n.r(e);var i={functional:!0,props:{type:{type:String,default:\"tip\"},text:String,vertical:{type:String,default:\"top\"}},render:function(t,e){var n=e.props,i=e.slots;return t(\"span\",{class:[\"badge\",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(346),n(41)),p=Object(r.a)(i,void 0,void 0,!1,null,\"69367c83\",null);e.default=p.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{358:function(t,s,i){\"use strict\";i.r(s);var e=i(41),n=Object(e.a)({},(function(){var t=this.$createElement,s=this._self._c||t;return s(\"ContentSlotsDistributor\",{attrs:{\"slot-key\":this.$parent.slotKey}},[s(\"h1\",{attrs:{id:\"开发简介\"}},[s(\"a\",{staticClass:\"header-anchor\",attrs:{href:\"#开发简介\"}},[this._v(\"#\")]),this._v(\" 开发简介\")]),this._v(\" \"),s(\"ul\",[s(\"li\",[this._v(\"数据库表说明\")]),this._v(\" \"),s(\"li\",[this._v(\"其它待续.......\")])])])}),[],!1,null,null,null);s.default=n.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{350:function(t,e,s){\"use strict\";s.r(e);var n=[\"There's nothing here.\",\"How did we get here?\",\"That's a Four-Oh-Four.\",\"Looks like we've got some broken links.\"],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(41),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e(\"div\",{staticClass:\"theme-container\"},[e(\"div\",{staticClass:\"theme-default-content\"},[e(\"h1\",[this._v(\"404\")]),this._v(\" \"),e(\"blockquote\",[this._v(this._s(this.getMsg()))]),this._v(\" \"),e(\"RouterLink\",{attrs:{to:\"/\"}},[this._v(\"\\n Take me home.\\n \")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]);","extractedComments":[]}

View File

@ -0,0 +1 @@
{"code":"(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[]]);","extractedComments":[]}

View File

@ -0,0 +1,2 @@
6d51a1c8539b2c9ee6132d0200d5d04a0a515f48 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"f0f9d87fb2787fa900f281f30eae436d\"}","integrity":"sha512-kf/PWODIPNDCEDdMHRVkst3YFx3eOcV3tRI9KCd4U8U+PjSGTQSaZN+SwyEU60/n7WFNzxASZrel9/9vAJiwLw==","time":1620889161343,"size":649}

View File

@ -0,0 +1,2 @@
47a90d3223551491008ab061b38514e335dfc684 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"8cb29b8390cdd802b1f8f2eed896e52c\"}","integrity":"sha512-pWSUYIrj9TWNLmuBothVHmUNdBV8wbOFYAAfcOq4neb/hw44RMfR5TzBBsnEt3P5TimzVBqjX+R2GyDoO7Nx7w==","time":1620889161761,"size":4559}

View File

@ -0,0 +1,2 @@
80066f6445572655bd9b16cffd2c284ab217d04e {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"9cd25a4bb62c1fc4432175122985a97a\"}","integrity":"sha512-IbFZpSIezJ8ceSebdR02q8crBj0SiiuKiC01gARtQ0bSz1kloeyj4dalupM2KLNZz4PU+njPCGw4pN9gnF8A6g==","time":1620889161239,"size":346}

View File

@ -0,0 +1,2 @@
98fb62f8c3e4ef360753aafb17d9432a085b818a {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"18fa6da6aebec687e080a7f7d2f707d6\"}","integrity":"sha512-pYs9Yk1slgs/1In9mq0Q6FO7otL0omk63RV/H66FhrNKHbupTv+BVZGwmnRqXie4LX6vZ0EuhIsB0NRuM01zdw==","time":1620889161311,"size":557}

View File

@ -0,0 +1,2 @@
dbac25f7f6f99e13032d1c06edfe9a635f2d1e90 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"77dd28ba3f58012afade42fbc4c94494\"}","integrity":"sha512-64MPvUU0178hrAd0dOAgUTIinB/EH8d9fSX5D3X/Fb8iswfivyYW9BcSW4kOYUQXADFsdqMkihoGn7dVxNqDIg==","time":1620889161240,"size":95}

View File

@ -0,0 +1,2 @@
7193734a2bb239441d8356506f144ee9d5f35c00 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"4dfe8d9453f3671fb489922ea43d1050\"}","integrity":"sha512-lYJ+VbXTyS6DoTQ7277fdJL7HGpOeeVwmC/dGRcB4F0MJWVmB8CWpPOEy6M1i8T37r3LZRBHVWfu6ALEh0ZHWQ==","time":1620889161498,"size":8630}

View File

@ -0,0 +1,2 @@
79d1c8808b7a10812ad6af174c642a6b81ed903d {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"851b16c53ad23f094c87773e9ebba4dc\"}","integrity":"sha512-x+wqAxYusZlbfADXB4tK6y9l/2VKxFsVzVtxhZ+5f9eXcnBPA34BsgJw2O9Zovx/EUcQP57MhESkxEYXJ+hEvQ==","time":1620889162052,"size":22237}

View File

@ -0,0 +1,2 @@
30b180d322755a0460afd1a0da1fb2a7105435c5 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"4d26b20d32a174c5b8a78d295a62faab\"}","integrity":"sha512-wc/+3qee2ZYF/YbEHgyYJK/KP6bzQKwxSu92fc+pxGAr6vW1i5zarzavVxg8/yI4zfKoVINCVcv5aZriv7hWLw==","time":1620889161581,"size":597}

View File

@ -0,0 +1,2 @@
6a486ee25ca3a736623c56bfcddff0bfb1736b1b {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"badc1bdcdb7e35cc328a28ae3b83beeb\"}","integrity":"sha512-8F8K1NlyySr8vN9IXrJ/lnMfZeojR6K+qkUN7+GX0nuWGsrUw83lmvNnICaBX6Tq86osZLNDD1bZccPu3xJQIQ==","time":1620889161744,"size":10016}

View File

@ -0,0 +1,2 @@
dbcc8854a042e86a6c43b864e742030e7605e382 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"045b359015e161e4e1ab37d5d385c904\"}","integrity":"sha512-O+U1FIL/ef6DEh6r/AoSVxCUTWAN3fxlKsB/L2k4CDLvpL0tYej2Kie385PGUuuL/h+iWURqq9PKOh36X5R86Q==","time":1620889162389,"size":47615}

View File

@ -0,0 +1,2 @@
363ce13c42a94dd05b53436ec9f7866502c70b11 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"13ba5e6ba8d0eec9202af68ec7dab242\"}","integrity":"sha512-5DqCGgBBgN8528QEAQ7yLG7qpxuj0pVWbS0Owf0Z7xOhNWJbuTWE1pCN/ng0iN6VzSEtFW6iHFbMqzcUYukVJA==","time":1620889161373,"size":772}

View File

@ -0,0 +1,2 @@
30bf343fcd65ed41fccfcaa6989eb0c7571add5c {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"e6cf699a69eee9034c41cde45ff6dcff\"}","integrity":"sha512-OTl2/YuySJvnb9qJkRUcrCpyNaNYJD2ROdPcA4H8xspjjAdL1oT+DBhBjrS1clAaoLyC61pw94SROPs3JIFqZA==","time":1620889162644,"size":65586}

View File

@ -0,0 +1,2 @@
6e93c537f94882608f621d0957fd59962490e7b4 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"30e1dfdb316f40612c1f88b293db7099\"}","integrity":"sha512-ISDmGhUCA5446q5bot5YTP5CxtMOi2L4b/AoZQKl3KlyggiUMzP2ZeuryNz5T+Jx/QFrGLhpoxvS9fCGKMa7FQ==","time":1620889161525,"size":7065}

View File

@ -0,0 +1,2 @@
ac369565e2c075b484744f6c06e4876179e7b652 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"6daee926d473cd6205908bf163d5d481\"}","integrity":"sha512-LEiR2+3UJDGB7Dzb202Qzfill+I5pkinlSYfzBA+nqXh1bd6FP6Rvp4apDw1H7dp873NMhS159jbmPzwuXtslg==","time":1620889162766,"size":35332}

View File

@ -0,0 +1,2 @@
8e63f872b1d51ec54d7da62d9f37921afde12709 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"ab13e7d94233bf1f671909ebfd5337d8\"}","integrity":"sha512-xjdrU+kqVrUuEDg80kIabVTEk9Yaehu7lYIjVkf+gAFRsYjG1KWMV1i8sBirDMjzhGoF0KWbhgvJqJxTEclQzQ==","time":1620889161631,"size":5788}

View File

@ -0,0 +1,2 @@
18401f476ef7ad5079fc3ce64a37a632e68902b9 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"445bfdc0cd5b49ddd11ec12543c6b14f\"}","integrity":"sha512-0AZQ2oMz+eiIQZd2nKPMALUz15oc49B/oN3DRPJMABjJKCC1cQup7X2oXGnfdialsWXuW7L888Y76UoQ9nsiJQ==","time":1620889162233,"size":17233}

View File

@ -0,0 +1,2 @@
bccf43e3e0ae0744e763290f3515c13fe2361036 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"4dc63b78a708ff8f79bf2707138d1155\"}","integrity":"sha512-YtCPVIgK4KZereFnTEDG7w6/bhTD2pmy+TBI+iSn/M0rAWHF5JCMQvgNf1A4OIG3ikiUdVtgTKubbrNuoFD6MQ==","time":1620889164423,"size":199518}

View File

@ -0,0 +1,2 @@
54da63f28ccad8378fd6d553c742d26591313ea2 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"41e92bb0343e69e376ff193eff8fb912\"}","integrity":"sha512-od9n1AAPY/fmy7u6KH1yLePuOm3xJnLWPSpzEBD39sIZMZIIov4tnUL+hTeZGVOFdJrx6CTnqLluFwYuLFwiyg==","time":1620889162778,"size":77565}

View File

@ -0,0 +1,2 @@
ad6886d0dca3f8f58721cb6a855d1ce4ac25a553 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"22efe4e5f17bfdf7d813438f8b867129\"}","integrity":"sha512-X5r+QjHFoxeykB/0opNhEmvQ5RXBFvbfnCblKYDwQqQxCPCqtkXMqC0fW34QB9q3rR62ZxD/oSl4Ui+8fYYcuw==","time":1620889161805,"size":623}

View File

@ -0,0 +1,2 @@
93e726f2128a296edd5e928fb9772062b7688d06 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v12.18.1\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"d839b78db478e8f4645795123f44a6f9\"}","integrity":"sha512-jTRW05ius5LBUCCO18MnoKQQz/F6YlbHoyAF1OXgH0ji5J+48DYMeTonwuqpSqY4h0jcXnK0lPGMvbPwU33Vig==","time":1620889161435,"size":1912}

View File

@ -1,13 +1,13 @@
{
"name": "docs",
"version": "1.0.0",
"description": "",
"description": "HOJ文档",
"main": "index.js",
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
},
"keywords": [],
"keywords": ["HOJ"],
"author": "Himit_ZH",
"license": "ISC"
}

View File

@ -1,231 +1 @@
## 1. Compile
#### Json Request Body
```json
{
"cmd": [{
"args": ["/usr/bin/g++", "a.cc", "-o", "a"],
"env": ["PATH=/usr/bin:/bin"],
"files": [{
"content": ""
}, {
"name": "stdout",
"max": 10240
}, {
"name": "stderr",
"max": 10240
}],
"cpuLimit": 10000000000,
"memoryLimit": 104857600,
"procLimit": 50,
"copyIn": {
"a.cc": {
"content": "#include <iostream>\nusing namespace std;\nint main() {\nint a, b;\ncin >> a >> b;\ncout << a + b << endl;\n}"
}
},
"copyOut": ["stdout", "stderr"],
"copyOutCached": ["a.cc", "a"],
"copyOutDir": "1"
}]
}
```
#### Json Response Data
```
[
{
"status": "Accepted",
"exitStatus": 0,
"time": 303225231,
"memory": 32243712,
"runTime": 524177700,
"files": {
"stderr": "",
"stdout": ""
},
"fileIds": {
"a": "5LWIZAA45JHX4Y4Z",
"a.cc": "NOHPGGDTYQUFRSLJ"
}
}
]
```
## 2. Test Case
#### Json Request Body
```json
{
"cmd": [{
"args": ["a"],
"env": ["PATH=/usr/bin:/bin","LANG=en_US.UTF-8","LC_ALL=en_US.UTF-8","LANGUAGE=en_US:en"],
"files": [{
"src": "/judge/test_case/problem_1010/1.in"
}, {
"name": "stdout",
"max": 10240
}, {
"name": "stderr",
"max": 10240
}],
"cpuLimit": 10000000000,
"realCpuLimit":30000000000,
"stackLimit":134217728,
"memoryLimit": 104811111,
"procLimit": 50,
"copyIn": {
"a":{"fileId":"WDQL5TNLRRVB2KAP"}
},
"copyOut": ["stdout", "stderr"]
}]
}
```
#### Json Response Data
```json
[{
"status": "Accepted",
"exitStatus": 0,
"time": 3171607,
"memory": 475136,
"runTime": 110396333,
"files": {
"stderr": "",
"stdout": "23\n"
}
}]
```
## 3. SPJ Test Case
#### Json Request Body
```json
{
"pipeMapping": [
{
"in": {
"max": 16777216,
"index": 0,
"fd": 1
},
"out": {
"index": 1,
"fd": 0
}
}
],
"cmd": [
{
"stackLimit": 134217728,
"cpuLimit": 3000000000,
"realCpuLimit": 9000000000,
"clockLimit": 64,
"env": [
"LANG=en_US.UTF-8",
"LANGUAGE=en_US:en",
"LC_ALL=en_US.UTF-8",
"PYTHONIOENCODING=utf-8"
],
"copyOut": [
"stderr"
],
"args": [
"/usr/bin/python3",
"main"
],
"files": [
{
"src": "/judge/test_case/problem_1002/5.in"
},
null,
{
"max": 16777216,
"name": "stderr"
}
],
"memoryLimit": 536870912,
"copyIn": {
"main": {
"fileId": "CGTRDEMKW5VAYN6O"
}
}
},
{
"stackLimit": 134217728,
"cpuLimit": 8000000000,
"clockLimit": 24000000000,
"env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=en_US.UTF-8",
"LANGUAGE=en_US:en",
"LC_ALL=en_US.UTF-8"
],
"copyOut": [
"stdout",
"stderr"
],
"args": [
"/w/spj",
"/w/tmp"
],
"files": [
null,
{
"max": 16777216,
"name": "stdout"
},
{
"max": 16777216,
"name": "stderr"
}
],
"memoryLimit": 536870912,
"copyIn": {
"spj": {
"src": "/judge/spj/1002/spj"
},
"tmp": {
"src": "/judge/test_case/problem_1002/5.out"
}
},
"procLimit": 64
}
]
```
#### Json Response Data
```json
[
{
"status": "Accepted",
"exitStatus": 0,
"time": 1545123,
"memory": 253952,
"runTime": 4148800,
"files": {
"stderr": ""
},
"fileIds": {}
},
{
"status": "Accepted",
"exitStatus": 0,
"time": 1501463,
"memory": 253952,
"runTime": 5897700,
"files": {
"stderr": "",
"stdout": ""
},
"fileIds": {}
}
]
```
> 这是安全沙盒可执行文件,具体使用请看[HOJ文档](http:s//www.hcode.top/docs)

File diff suppressed because it is too large Load Diff