mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 14:32:11 +01:00
Broken shit
This commit is contained in:
22
server.ts
22
server.ts
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user