trading-discipline-backend/start.sh
刘华勇 c19ca2aa4c feat: 初始化交易纪律系统后端
- 基于 axum + sqlx + tokio 的 Rust 后端服务
- 实现多数据源管理(东方财富/新浪/腾讯)含 failover 容错
- 数据源健康检查、请求日志记录与重放诊断
- 股票公司列表、历史K线、实时行情数据获取
- 配置 .gitignore:忽略 target 构建产物、.env 密钥、data 数据库
2026-06-17 15:46:48 +08:00

52 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# ============================================
# 交易纪律系统 - 后端启动脚本
# ============================================
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
echo "🎯 交易纪律管理系统 - 后端服务"
echo "================================"
# 检查端口占用
if lsof -i :8080 -t > /dev/null 2>&1; then
echo "⚠️ 端口 8080 已被占用,正在停止旧进程..."
lsof -i :8080 -t | xargs kill -9 2>/dev/null || true
sleep 1
fi
# 创建数据目录
mkdir -p data
echo "✅ 数据目录: $SCRIPT_DIR/data"
# 检查是否需要编译
if [ ! -f "target/release/trading-backend" ]; then
echo "🔨 首次运行正在编译Release 模式)..."
cargo build --release
fi
# 检查 Redis可选
if command -v redis-cli &> /dev/null; then
if redis-cli ping > /dev/null 2>&1; then
echo "✅ Redis 连接正常"
# 确保 .env 中启用了 Redis
if ! grep -q "^REDIS_URL" .env; then
echo "REDIS_URL=redis://127.0.0.1:6379" >> .env
fi
else
echo " Redis 未运行(缓存功能将不可用)"
fi
else
echo " Redis 未安装(缓存功能将不可用)"
fi
echo "================================"
echo "🚀 启动后端服务..."
# 启动
export RUST_LOG=${RUST_LOG:-info}
exec ./target/release/trading-backend