Update cluster-server.js

This commit is contained in:
Face 2025-05-30 14:35:59 +03:00
parent 2def8d7a00
commit 8ec300ac5c

View file

@ -1,6 +1,6 @@
import cluster from 'cluster'; import cluster from 'cluster';
import { cpus } from 'os'; import { cpus } from 'os';
import { handler } from './build/server/index.js'; import { Server } from './build/server/index.js';
import express from 'express'; import express from 'express';
const numCPUs = cpus().length; const numCPUs = cpus().length;
@ -14,7 +14,11 @@ if (cluster.isPrimary) {
}); });
} else { } else {
const app = express(); const app = express();
app.use(handler);
const server = new Server();
app.use(server.handler);
const port = process.env.PORT || 3000; const port = process.env.PORT || 3000;
app.listen(port, () => app.listen(port, () =>
console.log(`Worker ${process.pid} listening on ${port}`) console.log(`Worker ${process.pid} listening on ${port}`)