1
0

fix: 修复访问tushare接口过快

This commit is contained in:
2025-09-08 21:10:21 +08:00
parent f1ab38f871
commit 30225afcba
6 changed files with 71 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
#!/bin/bash
sudo rm -rf /tmp/leopard
git clone --depth 1 https://gitea.lanyuanxiaoyao.com/lanyuanxiaoyao/leopard.git /tmp/leopard
docker run \
--rm \
-v /root/.m2:/root/.m2 \
-v /tmp/leopard:/tmp/leopard \
-w /tmp/leopard \
maven:3.9.11-eclipse-temurin-17-alpine \
mvn -pl leopard-server clean package -D skipTests
docker run \
--rm \
-v /root/.pnpm-store:/root/.pnpm-store \
-v /tmp/leopard:/tmp/leopard \
-w /tmp/leopard/leopard-web \
guergeiro/pnpm:22-10-alpine \
/bin/sh -c "pnpm install && pnpm build"
sudo chown -R ubuntu:ubuntu /tmp/leopard
mv /tmp/leopard/leopard-server/target/leopard-server-1.0.0.jar /home/ubuntu/app/leopard-server-1.0.0.jar
bash /home/ubuntu/app/stop.sh
bash /home/ubuntu/app/start.sh

View File

@@ -0,0 +1,4 @@
#!/bin/bash
/home/ubuntu/app/stop.sh
/home/ubuntu/app/start.sh

View File

@@ -0,0 +1,3 @@
#!/bin/bash
nohup /home/ubuntu/jdk-17.0.16+8/bin/java -jar /home/ubuntu/app/leopard-server-1.0.0.jar --spring.profiles.active=build --spring.web.resources.static-locations=file:/home/ubuntu/app/web --logging.parent=/home/ubuntu/app > /dev/null 2>&1 &

View File

@@ -0,0 +1,33 @@
#!/bin/bash
original_command="$0"
application_name="/home/ubuntu/app/leopard-server-1.0.0.jar"
function get_pid() {
echo $(ps ef | grep "$application_name" | grep -v grep | awk '{ print $1 }')
}
pid=$(get_pid)
if [[ -z "$pid" ]]; then
echo "Application is already stopped."
exit 0
fi
echo "Stopping $pid..."
kill $pid
LOOPS=0
while (true); do
cpid=$(get_pid)
if [[ -z "$cpid" ]]; then
echo "Oook! cost:$LOOPS"
break
fi
LOOPS=$(($LOOPS+1))
if [[ $(($LOOPS%15)) -eq 0 ]]; then
echo "Wait timeout, try to force kill $pid..."
kill -9 $pid
fi
sleep 1s
done

View File

@@ -1,5 +1,6 @@
package com.lanyuanxiaoyao.leopard.server.service.task;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
@@ -41,14 +42,14 @@ public class CheckDailyNode extends NodeComponent {
.map(item -> LocalDate.parse(item.get(0), TuShareService.TRADE_FORMAT))
.filter(date -> date.isBefore(nowDate) || date.isEqual(nowDate))
.toList();
stocks.parallelStream()
.forEach(stock -> {
stocks.forEach(stock -> {
if (exchange.equals(stock.getMarket())) {
var existsTradeDates = dailyService.findDistinctTradeDateByStockId(stock.getId());
var missedTradeDates = allTradeDates.stream()
.filter(date -> date.isAfter(stock.getListedDate()) || date.isEqual(stock.getListedDate()))
.filter(date -> !existsTradeDates.contains(date))
.filter(date -> {
ThreadUtil.safeSleep(100);
var response = tuShareService.dailyList(date, stock.getCode());
return !response.data().items().isEmpty();
})