Broken shit

This commit is contained in:
Max Kowalski
2025-06-26 21:00:19 +02:00
parent ab2c75b736
commit 653d70022b
49 changed files with 2826 additions and 2102 deletions

View File

@ -2,8 +2,7 @@
import { createServer } from "http";
import { parse } from "url";
import next from "next";
import { startScheduler } from "./lib/scheduler.js";
import { startProcessingScheduler } from "./lib/processingScheduler.js";
import { processUnprocessedSessions } from "./lib/processingSchedulerNoCron.js";
const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost";
@ -14,11 +13,20 @@ const app = next({ dev, hostname, port });
const handle = app.getRequestHandler();
app.prepare().then(() => {
// Initialize schedulers when the server starts
console.log("Starting schedulers...");
startScheduler();
startProcessingScheduler();
console.log("All schedulers initialized successfully");
// Start processing scheduler in the background
const BATCH_SIZE = 10;
const MAX_CONCURRENCY = 5;
const SCHEDULER_INTERVAL = 5 * 60 * 1000; // 5 minutes
// Initial processing run
processUnprocessedSessions(BATCH_SIZE, MAX_CONCURRENCY).catch(console.error);
// Schedule regular processing
setInterval(() => {
processUnprocessedSessions(BATCH_SIZE, MAX_CONCURRENCY).catch(console.error);
}, SCHEDULER_INTERVAL);
console.log("Processing scheduler started with 5 minute interval");
createServer(async (req, res) => {
try {