myTestFreqAI/system_restart.sh
2025-08-18 03:10:39 +08:00

78 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# 系统性修复时间戳问题的脚本
echo "🚀 开始系统性修复时间戳问题..."
# 1. 停止当前运行的Freqtrade服务
echo "📍 步骤1: 停止当前服务..."
pkill -f "freqtrade trade" || echo "没有运行的服务"
# 2. 清理缓存数据
echo "📍 步骤2: 清理缓存数据..."
cd /Users/zhangkun/myTestFreqAI
# 备份现有缓存
if [ -d "user_data/data" ]; then
echo "🗂️ 备份现有数据..."
cp -r user_data/data user_data/data_backup_$(date +%Y%m%d_%H%M%S)
fi
# 清理缓存文件
echo "🧹 清理缓存文件..."
rm -rf user_data/data/*
rm -rf user_data/hyperopt_results/*
rm -rf user_data/plots/*
# 3. 检查配置文件
echo "📍 步骤3: 检查配置文件..."
if [ -f "config.json" ]; then
echo "✅ 找到配置文件"
# 检查是否有时间配置问题
python3 -c "
import json
with open('config.json') as f:
config = json.load(f)
print('时间框架:', config.get('timeframe', '未设置'))
print('交易所:', config.get('exchange', {}).get('name', '未设置'))
"
else
echo "❌ 未找到config.json"
fi
# 4. 验证策略文件
echo "📍 步骤4: 验证策略文件..."
cd /Users/zhangkun/myTestFreqAI/freqtrade/templates
python3 -m py_compile freqaiprimer.py
if [ $? -eq 0 ]; then
echo "✅ 策略文件语法正确"
else
echo "❌ 策略文件语法错误"
exit 1
fi
# 5. 重启服务
echo "📍 步骤5: 重启服务..."
cd /Users/zhangkun/myTestFreqAI
# 使用nohup后台运行
echo "🔄 启动Freqtrade服务..."
nohup freqtrade trade -c config.json > freqtrade_restart.log 2>&1 &
# 等待服务启动
sleep 5
# 检查服务状态
if pgrep -f "freqtrade trade" > /dev/null; then
echo "✅ 服务已成功重启"
echo "📊 查看日志: tail -f freqtrade_restart.log"
else
echo "❌ 服务启动失败"
echo "📋 查看错误日志: cat freqtrade_restart.log"
fi
echo "🎉 修复完成!"
echo "📋 下一步操作:"
echo "1. 观察日志: tail -f freqtrade_restart.log"
echo "2. 检查时间戳错误是否消失"
echo "3. 如果问题仍然存在,请检查配置文件"