update Scheduled task
This commit is contained in:
parent
c9bad95f43
commit
42327ffde0
|
@ -16,5 +16,5 @@ features:
|
|||
details: 判题使用 cgroup 隔离用户程序,网站权限控制完善
|
||||
- title: 多样化
|
||||
details: 独有自身判题服务,同时支持其它知名OJ题目的提交判题
|
||||
footer: MIT Licensed | Copyright © 2021.12.12 @Author Himit_ZH QQ Group:598587305
|
||||
footer: MIT Licensed | Copyright © 2021.12.14 @Author Himit_ZH QQ Group:598587305
|
||||
---
|
|
@ -28,6 +28,9 @@
|
|||
> 注意:各服务ip最好不改动,保持处于172.20.0.0/16网段的docker network
|
||||
|
||||
```properties
|
||||
# hoj全部数据存储的文件夹位置(默认当前路径生成hoj文件夹)
|
||||
HOJ_DATA_DIRECTORY=./hoj
|
||||
|
||||
# redis的配置
|
||||
REDIS_HOST=172.20.0.2
|
||||
REDIS_PORT=6379
|
||||
|
@ -35,7 +38,8 @@
|
|||
|
||||
# mysql的配置
|
||||
MYSQL_HOST=172.20.0.3
|
||||
MYSQL_PUBLIC_HOST=172.20.0.3 # 如果判题服务是分布式,请提供当前mysql所在服务器的公网ip
|
||||
# 如果判题服务是分布式,请提供当前mysql所在服务器的公网ip
|
||||
MYSQL_PUBLIC_HOST=172.20.0.3
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_ROOT_PASSWORD=hoj123456
|
||||
|
||||
|
@ -48,13 +52,18 @@
|
|||
# backend后端服务的配置
|
||||
BACKEND_HOST=172.20.0.5
|
||||
BACKEND_PORT=6688
|
||||
JWT_TOKEN_SECRET=default # token加密秘钥 默认则生成32位随机密钥
|
||||
JWT_TOKEN_EXPIRE=86400 # token过期时间默认为24小时 86400s
|
||||
JWT_TOKEN_FRESH_EXPIRE=43200 # token默认12小时可自动刷新
|
||||
JUDGE_TOKEN=default # 调用判题服务器的token 默认则生成32位随机密钥
|
||||
EMAIL_SERVER_HOST=smtp.qq.com # 请使用邮件服务的域名或ip
|
||||
# token加密秘钥 默认则生成32位随机密钥
|
||||
JWT_TOKEN_SECRET=default
|
||||
# token过期时间默认为24小时 86400s
|
||||
JWT_TOKEN_EXPIRE=86400
|
||||
# token默认12小时可自动刷新
|
||||
JWT_TOKEN_FRESH_EXPIRE=43200
|
||||
# 调用判题服务器的token 默认则生成32位随机密钥
|
||||
JUDGE_TOKEN=default
|
||||
# 请使用邮件服务的域名或ip
|
||||
EMAIL_SERVER_HOST=smtp.qq.com
|
||||
EMAIL_SERVER_PORT=465
|
||||
EMAIL_USERNMAE=your_email_username
|
||||
EMAIL_USERNAME=your_email_username
|
||||
EMAIL_PASSWORD=your_email_password
|
||||
# 开启虚拟判题请提供对应oj的账号密码 格式为
|
||||
# username1,username2,...
|
||||
|
@ -188,6 +197,9 @@ Password: 开启SMTP服务后生成的随机授权码
|
|||
> 注意:各服务ip最好不改动,保持处于172.20.0.0/16网段的docker network
|
||||
|
||||
```properties
|
||||
# hoj全部数据存储的文件夹位置(默认当前路径生成hoj文件夹)
|
||||
HOJ_DATA_DIRECTORY=./hoj
|
||||
|
||||
# redis的配置
|
||||
REDIS_HOST=172.20.0.2
|
||||
REDIS_PORT=6379
|
||||
|
@ -195,7 +207,8 @@ Password: 开启SMTP服务后生成的随机授权码
|
|||
|
||||
# mysql的配置
|
||||
MYSQL_HOST=172.20.0.3
|
||||
MYSQL_PUBLIC_HOST=172.20.0.3 # 请提供当前mysql所在服务器的公网ip
|
||||
# 请提供当前mysql所在服务器的公网ip
|
||||
MYSQL_PUBLIC_HOST=172.20.0.3
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_ROOT_PASSWORD=hoj123456
|
||||
|
||||
|
@ -208,13 +221,18 @@ Password: 开启SMTP服务后生成的随机授权码
|
|||
# backend后端服务的配置
|
||||
BACKEND_HOST=172.20.0.5
|
||||
BACKEND_PORT=6688
|
||||
JWT_TOKEN_SECRET=default # token加密秘钥 默认则生成32位随机密钥
|
||||
JWT_TOKEN_EXPIRE=86400 # token过期时间默认为24小时 86400s
|
||||
JWT_TOKEN_FRESH_EXPIRE=43200 # token默认12小时可自动刷新
|
||||
JUDGE_TOKEN=default # 调用判题服务器的token 默认则生成32位随机密钥
|
||||
EMAIL_SERVER_HOST=smtp.qq.com # 请使用邮件服务的域名或ip
|
||||
# token加密秘钥 默认则生成32位随机密钥
|
||||
JWT_TOKEN_SECRET=default
|
||||
# token过期时间默认为24小时 86400s
|
||||
JWT_TOKEN_EXPIRE=86400
|
||||
# token默认12小时可自动刷新
|
||||
JWT_TOKEN_FRESH_EXPIRE=43200
|
||||
# 调用判题服务器的token 默认则生成32位随机密钥
|
||||
JUDGE_TOKEN=default
|
||||
# 请使用邮件服务的域名或ip
|
||||
EMAIL_SERVER_HOST=smtp.qq.com
|
||||
EMAIL_SERVER_PORT=465
|
||||
EMAIL_USERNMAE=your_email_username
|
||||
EMAIL_USERNAME=your_email_username
|
||||
EMAIL_PASSWORD=your_email_password
|
||||
# 开启虚拟判题请提供对应oj的账号密码 格式为
|
||||
# username1,username2,...
|
||||
|
@ -227,7 +245,8 @@ Password: 开启SMTP服务后生成的随机授权码
|
|||
POJ_ACCOUNT_PASSWORD_LIST=
|
||||
|
||||
# 评测数据同步的配置
|
||||
RSYNC_PASSWORD=hoj123456 # 请修改数据同步密码
|
||||
# 请修改数据同步密码
|
||||
RSYNC_PASSWORD=hoj123456
|
||||
|
||||
# docker network的配置
|
||||
SUBNET=172.20.0.0/16
|
||||
|
@ -254,23 +273,36 @@ Password: 开启SMTP服务后生成的随机授权码
|
|||
4. 接着,在另一台服务器上,依旧git clone该文件夹下来,然后进入`judgeserver`文件夹,修改`.env`的配置
|
||||
|
||||
```properties
|
||||
# hoj全部数据存储的文件夹位置(默认当前路径生成judge文件夹)
|
||||
HOJ_JUDGESERVER_DATA_DIRECTORY=./judge
|
||||
|
||||
# nacos的配置
|
||||
NACOS_HOST=NACOS_HOST # 修改为nacos所在服务的ip,即主服务器的公网ip
|
||||
NACOS_PORT=8848 # 修改为nacos启动端口号,默认为8848
|
||||
NACOS_USERNAME=root # 修改为nacos的管理员账号
|
||||
NACOS_PASSWORD=hoj123456 # 修改为nacos的管理员密码
|
||||
# 修改为nacos所在服务的ip
|
||||
NACOS_HOST=NACOS_HOST
|
||||
# 修改为nacos启动端口号,默认为8848
|
||||
NACOS_PORT=8848
|
||||
# 修改为nacos的管理员账号
|
||||
NACOS_USERNAME=root
|
||||
# 修改为nacos的管理员密码
|
||||
NACOS_PASSWORD=hoj123456
|
||||
|
||||
# judgeserver的配置
|
||||
JUDGE_SERVER_IP=172.20.0.7 # 修改为当前的服务器公网ip
|
||||
JUDGE_SERVER_PORT=8088 # judgeserver启动端口号
|
||||
#修改服务器公网ip
|
||||
JUDGE_SERVER_IP=172.20.0.7
|
||||
JUDGE_SERVER_PORT=8088
|
||||
JUDGE_SERVER_NAME=judger-1
|
||||
MAX_TASK_NUM=-1 # -1表示最大并行任务数为cpu核心数+1
|
||||
REMOTE_JUDGE_OPEN=true # 当前判题服务器是否开启远程虚拟判题功能
|
||||
REMOTE_JUDGE_MAX_TASK_NUM=-1 # -1表示最大并行任务数为cpu核心数*2+1
|
||||
# -1表示最大并行任务数为cpu核心数+1
|
||||
MAX_TASK_NUM=-1
|
||||
# 当前判题服务器是否开启远程虚拟判题功能
|
||||
REMOTE_JUDGE_OPEN=true
|
||||
# -1表示最大并行任务数为cpu核心数*2+1
|
||||
REMOTE_JUDGE_MAX_TASK_NUM=-1
|
||||
|
||||
# rsync评测数据同步的配置
|
||||
RSYNC_MASTER_ADDR=127.0.0.1 # 写入主服务器ip
|
||||
RSYNC_PASSWORD=hoj123456 # 与主服务器的rsync密码一致
|
||||
# 写入主服务器ip
|
||||
RSYNC_MASTER_ADDR=127.0.0.1
|
||||
# 与主服务器的rsync密码一致
|
||||
RSYNC_PASSWORD=hoj123456
|
||||
```
|
||||
|
||||
配置修改保存后,当前路径下启动该服务
|
||||
|
|
|
@ -82,7 +82,7 @@ docker-compose up -d
|
|||
|
||||
> 附加:如何自定义前端请看这里 => [自定义前端文档](/use/update-fe.html)
|
||||
|
||||
(1)首先到`./hoj/hoj-vue`文件夹中,拉取[hoj-vue](https://gitee.com/himitzh0730/hoj/tree/master/hoj-vue)仓库最新的代码,可能会覆盖本地的修改,请注意合并分支。
|
||||
(1)首先到`./hoj/hoj-vue`文件夹中,拉取[hoj-vue](https://gitee.com/himitzh0730/hoj/tree/master/hoj-vue)仓库最新的代码,请注意解决出现的冲突。
|
||||
|
||||
```shell
|
||||
git pull
|
||||
|
@ -90,6 +90,16 @@ git pull
|
|||
|
||||
或者重新直接download成zip包,然后重新自定义修改前端
|
||||
|
||||
当然,如果想查看对比主仓库更新的内容,可以用以下命令一步步合并
|
||||
|
||||
```bash
|
||||
git remote -v # 查看主仓库的远程仓库
|
||||
git fetch origin master:temp # 将最新的主仓库代码拉到本地一个temp的分支
|
||||
git diff temp # 比较现在本地代码与最新temp分支的区别
|
||||
git merge temp # 合并temp分支到本地的master分支
|
||||
git branch -d temp # 删除temp这个临时分支
|
||||
```
|
||||
|
||||
(2)接着,重新用npm打包,在`./hoj/hoj-vue/dist`文件夹会生成静态的前端文件,放到原来指定的位置即可
|
||||
|
||||
```shell
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
</resources>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>top.hcode</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
|
|
|
@ -3,7 +3,6 @@ package top.hcode.hoj;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
|
|
@ -8,4 +8,5 @@ import top.hcode.hoj.pojo.entity.user.Session;
|
|||
@Mapper
|
||||
@Repository
|
||||
public interface SessionMapper extends BaseMapper<Session> {
|
||||
|
||||
}
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="top.hcode.hoj.dao.SessionMapper">
|
||||
|
||||
|
||||
</mapper>
|
|
@ -9,6 +9,7 @@ import cn.hutool.json.JSONObject;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
|
@ -32,6 +33,7 @@ import top.hcode.hoj.utils.RedisUtils;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -258,13 +260,18 @@ public class ScheduleServiceImpl implements ScheduleService {
|
|||
} catch (Exception e) {
|
||||
log.error("爬虫爬取Codeforces Rating分数异常----------------------->{}", e.getMessage());
|
||||
}
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
log.info("获取Codeforces Rating成功!");
|
||||
}
|
||||
|
||||
@Retryable(value = Exception.class,
|
||||
maxAttempts = 5,
|
||||
backoff = @Backoff(delay = 500, multiplier = 1.4))
|
||||
backoff = @Backoff(delay = 1000, multiplier = 1.4))
|
||||
public JSONObject getCFUserInfo(String url) throws Exception {
|
||||
return JsoupUtils.getJsonFromConnection(JsoupUtils.getConnectionFromUrl(url, null, null));
|
||||
}
|
||||
|
@ -278,19 +285,21 @@ public class ScheduleServiceImpl implements ScheduleService {
|
|||
* @Since 2021/9/6
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 * * *")
|
||||
// @Scheduled(cron = "0/5 * * * * *")
|
||||
@Override
|
||||
public void deleteUserSession() {
|
||||
QueryWrapper<Session> sessionQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
DateTime dateTime = DateUtil.offsetMonth(new Date(), -6);
|
||||
String strTime = DateFormatUtils.format(dateTime, "yyyy-MM-dd HH:mm:ss");
|
||||
sessionQueryWrapper.select("distinct uid");
|
||||
sessionQueryWrapper.ge("gmt_create", dateTime.toJdkDate());
|
||||
sessionQueryWrapper.apply("UNIX_TIMESTAMP(gmt_create) >= UNIX_TIMESTAMP('" + strTime + "')");
|
||||
List<Session> sessionList = sessionService.list(sessionQueryWrapper);
|
||||
if (sessionList.size() > 0) {
|
||||
List<String> uidList = sessionList.stream().map(Session::getUid).collect(Collectors.toList());
|
||||
UpdateWrapper<Session> sessionUpdateWrapper = new UpdateWrapper<>();
|
||||
sessionQueryWrapper.in("uid", uidList)
|
||||
.lt("gmt_create", dateTime.toJdkDate());
|
||||
.apply("UNIX_TIMESTAMP('" + strTime + "') > UNIX_TIMESTAMP(gmt_create)");
|
||||
boolean isSuccess = sessionService.remove(sessionUpdateWrapper);
|
||||
if (!isSuccess) {
|
||||
log.error("=============数据库session表定时删除用户6个月前的记录失败===============");
|
||||
|
|
|
@ -36,10 +36,6 @@
|
|||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<artifactId>hoj-springboot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>DataBackup</module>
|
||||
<module>api</module>
|
||||
<module>DataBackup</module>
|
||||
<module>JudgeServer</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
|
|
@ -437,7 +437,7 @@ export default {
|
|||
keyword: '',
|
||||
cid: '',
|
||||
currentPage: 1,
|
||||
limit: 8,
|
||||
limit: 10,
|
||||
pid: '',
|
||||
onlyMine: false,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue