27 lines
931 B
TypeScript
27 lines
931 B
TypeScript
/**
|
||
* 独立进程入口:平滑热力在子进程跑,避免阻塞主进程事件循环(HTTP / Vite)。
|
||
* 开发:node --import tsx server/smoothHeatmapJobRunner.ts <resultId> <taskId> <totalPoints>
|
||
* 生产:node dist/smoothHeatmapJobRunner.js ...
|
||
*/
|
||
import 'dotenv/config';
|
||
import { runSmoothHeatmapJob } from './smoothHeatmapJob.js';
|
||
|
||
const [, , a, b, c] = process.argv;
|
||
const resultId = Number(a);
|
||
const taskId = Number(b);
|
||
const totalPoints = Number(c);
|
||
|
||
if (!Number.isFinite(resultId) || !Number.isFinite(taskId) || resultId <= 0 || taskId <= 0) {
|
||
console.error('[SmoothHeatmapJobRunner] 用法: <resultId> <taskId> <totalPoints>');
|
||
process.exit(1);
|
||
}
|
||
|
||
const pts = Number.isFinite(totalPoints) && totalPoints > 0 ? totalPoints : 400_000;
|
||
|
||
runSmoothHeatmapJob(resultId, taskId, pts)
|
||
.then(() => process.exit(0))
|
||
.catch((e) => {
|
||
console.error('[SmoothHeatmapJobRunner]', e);
|
||
process.exit(1);
|
||
});
|