feat(cron): 实现定时任务管理功能

- 新增 cron模块,支持定时任务管理- 实现了任务列表获取、任务添加、任务移除和任务状态获取等接口
- 添加了默认任务,包括数据同步、数据清理、健康检查和缓存刷新等
- 实现了优雅关闭功能,确保在服务停止时正确停止所有任务
- 添加了定时任务相关文档和使用指南
This commit is contained in:
hu xiaotong
2025-06-23 15:19:38 +08:00
parent 89a6cdc001
commit cecb19e497
16 changed files with 1571 additions and 7 deletions

49
scripts/start.bat Normal file
View File

@@ -0,0 +1,49 @@
@echo off
chcp 65001 >nul
echo ==========================================
echo Epic Game Web Service
echo Starting with cron jobs enabled...
echo ==========================================
REM 检查Go环境
go version >nul 2>&1
if errorlevel 1 (
echo Error: Go is not installed or not in PATH
pause
exit /b 1
)
REM 检查Go版本
for /f "tokens=3" %%i in ('go version') do set GO_VERSION=%%i
echo Go version: %GO_VERSION%
REM 设置环境变量
set GO_ENV=production
set GF_GCFG_FILE=manifest/config/config.yaml
REM 清理旧的构建文件
echo Cleaning old build files...
if exist main.exe del main.exe
if exist main del main
REM 构建项目
echo Building project...
go build -o main.exe .
if errorlevel 1 (
echo Error: Build failed
pause
exit /b 1
)
echo Build successful!
REM 启动服务
echo Starting server on port 8283...
echo Cron jobs will be started automatically...
echo Press Ctrl+C to stop the server
echo ==========================================
REM 运行服务
main.exe

47
scripts/start.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
# Epic Game Web Service 启动脚本
echo "=========================================="
echo "Epic Game Web Service"
echo "Starting with cron jobs enabled..."
echo "=========================================="
# 检查Go环境
if ! command -v go &> /dev/null; then
echo "Error: Go is not installed or not in PATH"
exit 1
fi
# 检查Go版本
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
echo "Go version: $GO_VERSION"
# 设置环境变量
export GO_ENV=production
export GF_GCFG_FILE=manifest/config/config.yaml
# 清理旧的构建文件
echo "Cleaning old build files..."
rm -f main.exe
rm -f main
# 构建项目
echo "Building project..."
go build -o main.exe .
if [ $? -ne 0 ]; then
echo "Error: Build failed"
exit 1
fi
echo "Build successful!"
# 启动服务
echo "Starting server on port 8283..."
echo "Cron jobs will be started automatically..."
echo "Press Ctrl+C to stop the server"
echo "=========================================="
# 运行服务
./main.exe