core: pm2 cluster management

This commit is contained in:
undefined committed 2021-09-09 06:18:16 +08:00
1 parent 9f5c00a985
commit 448c398d21
30 files changed
+206 -427

No files matched your search

+3 -4
View File
@@ -1,17 +1,16 @@
import cluster from 'cluster';
const versionNum = +process.version.replace(/v/gim, '').split('.')[0];
if (versionNum < 10) throw new Error('NodeJS >=10.4 required');
else if (versionNum < 14 && cluster.isMaster) {
else if (versionNum < 14 && process.env.NODE_APP_INSTANCE === '0') {
console.warn('NodeJS version <14, startup performance will be impacted.');
}
console.log('Process', process.pid, 'running as', process.env.NODE_APP_INSTANCE === '0' ? 'master' : 'worker');
if (!global.Hydro) {
global.Hydro = {
version: {
node: process.version,
hydrooj: require('hydrooj/package.json').version,
},
stat: { reqCount: 0 },
handler: {},
// @ts-ignore
service: {},