@midwayjs/web
Version:
Midway Web Framework for Egg.js
34 lines • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@midwayjs/core");
const path_1 = require("path");
const util_1 = require("util");
const debug = (0, util_1.debuglog)('midway:debug');
function runInAgent() {
return (process.title.indexOf('agent') !== -1 ||
(process.argv[1] && process.argv[1].indexOf('agent_worker') !== -1));
}
// 多进程模式,从 egg-scripts 启动的
process.env['EGG_CLUSTER_MODE'] = 'true';
const isAgent = runInAgent();
debug('[egg]: run with egg-scripts in worker and init midway container in cluster mode');
const appDir = JSON.parse(process.argv[2])?.baseDir ?? process.cwd();
let baseDir;
if ((0, core_1.isTypeScriptEnvironment)()) {
baseDir = (0, path_1.join)(appDir, 'src');
}
else {
baseDir = (0, path_1.join)(appDir, 'dist');
}
(0, core_1.prepareGlobalApplicationContext)({
appDir,
baseDir,
// ignore: ['**/app/extend/**', '**/app/public/**'],
});
if (!isAgent) {
debug('[egg]: run with egg-scripts in worker and init midway container complete');
}
else {
debug('[egg]: run with egg-scripts in agent and init midway container complete');
}
//# sourceMappingURL=cluster.js.map