Spaces:
Sleeping
Sleeping
Upload server.js
Browse files
server.js
CHANGED
|
@@ -31,9 +31,10 @@ if (typeof global.File === "undefined") {
|
|
| 31 |
*/
|
| 32 |
|
| 33 |
if (cluster.isPrimary) {
|
| 34 |
-
|
|
|
|
| 35 |
console.log(`[HighScale] Primary process ${process.pid} is starting...`);
|
| 36 |
-
console.log(`[HighScale] Spawning ${numCPUs} worker processes
|
| 37 |
|
| 38 |
// Fork workers for each CPU core
|
| 39 |
for (let i = 0; i < numCPUs; i++) {
|
|
@@ -398,6 +399,6 @@ Rules:
|
|
| 398 |
|
| 399 |
app.get("/", (req, res) => res.send(`Prachee ai [Worker ${process.pid}] is powering the vibe! 🛸`));
|
| 400 |
|
| 401 |
-
const PORT = 7860;
|
| 402 |
-
app.listen(PORT, () => console.log(`[Worker ${process.pid}]
|
| 403 |
}
|
|
|
|
| 31 |
*/
|
| 32 |
|
| 33 |
if (cluster.isPrimary) {
|
| 34 |
+
// Limit workers to prevent OOM in container environments
|
| 35 |
+
const numCPUs = Math.min(os.cpus().length, 3);
|
| 36 |
console.log(`[HighScale] Primary process ${process.pid} is starting...`);
|
| 37 |
+
console.log(`[HighScale] Spawning ${numCPUs} worker processes...`);
|
| 38 |
|
| 39 |
// Fork workers for each CPU core
|
| 40 |
for (let i = 0; i < numCPUs; i++) {
|
|
|
|
| 399 |
|
| 400 |
app.get("/", (req, res) => res.send(`Prachee ai [Worker ${process.pid}] is powering the vibe! 🛸`));
|
| 401 |
|
| 402 |
+
const PORT = process.env.PORT || 7860;
|
| 403 |
+
app.listen(PORT, '0.0.0.0', () => console.log(`[Worker ${process.pid}] Server running on port ${PORT}`));
|
| 404 |
}
|