Update cluster-server.js
This commit is contained in:
parent
2def8d7a00
commit
8ec300ac5c
1 changed files with 7 additions and 3 deletions
|
|
@ -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}`)
|
||||||
|
|
|
||||||
Reference in a new issue