mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: pm2 cluster management
This commit is contained in:
1 parent
9f5c00a985
commit
448c398d21
30 files changed
+206
-427
No files matched your search
@@ -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: {},
|
||||
|
||||
Reference in new issue
Block a user