Use 1 thread on platform where fetching thread/core count fails
This commit is contained in:
parent
c3f69bc6d8
commit
1cc159348a
@ -7,7 +7,12 @@ config();
|
|||||||
import { FosscordServer } from "./Server";
|
import { FosscordServer } from "./Server";
|
||||||
import cluster from "cluster";
|
import cluster from "cluster";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
const cores = Number(process.env.THREADS) || os.cpus().length;
|
var cores = 1;
|
||||||
|
try {
|
||||||
|
cores = Number(process.env.THREADS) || os.cpus().length;
|
||||||
|
} catch {
|
||||||
|
console.log("[API] Failed to get thread count! Using 1...")
|
||||||
|
}
|
||||||
|
|
||||||
if (cluster.isMaster && process.env.NODE_ENV == "production") {
|
if (cluster.isMaster && process.env.NODE_ENV == "production") {
|
||||||
console.log(`Primary ${process.pid} is running`);
|
console.log(`Primary ${process.pid} is running`);
|
||||||
|
@ -3,8 +3,13 @@ const cluster = require("cluster");
|
|||||||
const WebSocket = require("ws");
|
const WebSocket = require("ws");
|
||||||
const endpoint = process.env.GATEWAY || "ws://localhost:3001";
|
const endpoint = process.env.GATEWAY || "ws://localhost:3001";
|
||||||
const connections = Number(process.env.CONNECTIONS) || 50;
|
const connections = Number(process.env.CONNECTIONS) || 50;
|
||||||
const threads = Number(process.env.THREADS) || require("os").cpus().length || 1;
|
|
||||||
const token = process.env.TOKEN;
|
const token = process.env.TOKEN;
|
||||||
|
var cores = 1;
|
||||||
|
try {
|
||||||
|
cores = Number(process.env.THREADS) || os.cpus().length;
|
||||||
|
} catch {
|
||||||
|
console.log("[Bundle] Failed to get thread count! Using 1...")
|
||||||
|
}
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
console.error("TOKEN env var missing");
|
console.error("TOKEN env var missing");
|
||||||
|
@ -9,7 +9,12 @@ config();
|
|||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
// TODO: add socket event transmission
|
// TODO: add socket event transmission
|
||||||
let cores = Number(process.env.THREADS) || os.cpus().length;
|
var cores = 1;
|
||||||
|
try {
|
||||||
|
cores = Number(process.env.THREADS) || os.cpus().length;
|
||||||
|
} catch {
|
||||||
|
console.log("[API] Failed to get thread count! Using 1...")
|
||||||
|
}
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
function getCommitOrFail() {
|
function getCommitOrFail() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user