UNPKG

@midwayjs/web

Version:

Midway Web Framework for Egg.js

35 lines 1.29 kB
"use strict"; var _a, _b; 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 = (_b = (_a = JSON.parse(process.argv[2])) === null || _a === void 0 ? void 0 : _a.baseDir) !== null && _b !== void 0 ? _b : 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