主要改动: 1. TCP缓冲区优化(16MB)- 解决公网上传速度慢问题 2. 并发数降低到1-3 - 避免4并发导致ERR_CONNECTION_RESET 3. 动态并发控制 - 根据网络环境自动调整 4. Nginx超时增加到120s - 支持大分片上传 5. 上传进度修复 - 修复剩余时间计算 6. 新增任务-页面上传器和详情组件 7. 统一部署文档为deploy-remote-build.ps1 问题修复: - 公网用户上传从200-900KB/s提升到预期3-5MB/s - 内网用户上传更稳定,无连接重置错误 - UploadProgress组件剩余时间计算修正 Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
// 内存使用监控API
|
|
import { NextResponse } from 'next/server';
|
|
|
|
// 导入内存监控模块(确保它被加载和启动)
|
|
import '@/lib/memory-monitor';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const usage = process.memoryUsage();
|
|
const uptime = process.uptime();
|
|
|
|
// 格式化内存使用
|
|
const formatBytes = (bytes: number) => {
|
|
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
|
|
};
|
|
|
|
// 计算运行时长
|
|
const formatUptime = (seconds: number) => {
|
|
const hours = Math.floor(seconds / 3600);
|
|
const minutes = Math.floor((seconds % 3600) / 60);
|
|
return `${hours}h ${minutes}m`;
|
|
};
|
|
|
|
return NextResponse.json({
|
|
memory: {
|
|
rss: formatBytes(usage.rss),
|
|
heapTotal: formatBytes(usage.heapTotal),
|
|
heapUsed: formatBytes(usage.heapUsed),
|
|
external: formatBytes(usage.external),
|
|
arrayBuffers: formatBytes(usage.arrayBuffers),
|
|
},
|
|
raw: {
|
|
rss: usage.rss,
|
|
heapTotal: usage.heapTotal,
|
|
heapUsed: usage.heapUsed,
|
|
external: usage.external,
|
|
arrayBuffers: usage.arrayBuffers,
|
|
},
|
|
uptime: formatUptime(uptime),
|
|
uptimeSeconds: uptime,
|
|
timestamp: new Date().toISOString(),
|
|
});
|
|
} catch (error) {
|
|
console.error('[Memory API] Error:', error);
|
|
return NextResponse.json(
|
|
{ error: '获取内存信息失败' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|