对native增加了对page注入path,修改了server中的个别环境参数侦测

This commit is contained in:
Xu Chang 2023-11-29 18:50:11 +08:00
parent 44c9616456
commit a0cc0c8ee1
3 changed files with 13 additions and 3 deletions

View File

@ -21,6 +21,7 @@ const nullthrows = require("nullthrows");
const replaceEnvExpressionPlugin = require('./babelEnvPlugin');
const { injectGetRender } = require('../utils/injectGetRender');
const oakPathTsxPlugin = require('../babel-plugin/oakPath');
async function renderToCSS({ src, filename, options = {} }) {
const { lessOptions = {} } = options;
@ -50,7 +51,7 @@ function transform({ filename, options, plugins, src }) {
cwd: options.projectRoot,
highlightCode: true,
filename,
plugins: plugins.concat(replaceEnvExpressionPlugin),
plugins: plugins.concat([replaceEnvExpressionPlugin, oakPathTsxPlugin]),
sourceType: "module",
// NOTE(EvanBacon): We split the parse/transform steps up to accommodate
// Hermes parsing, but this defaults to cloning the AST which increases

View File

@ -27,7 +27,7 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
allowedHeaders: ["oak-cxt"],
};
const io = new socket_io_1.Server(httpServer, socketOption);
if (process.env.PM2_STATUS) {
if (process.env.pm_id || process.env.PM_ID) {
// pm2环境下要接入clusterAdapter
// https://socket.io/zh-CN/docs/v4/pm2/
io.adapter((0, cluster_adapter_1.createAdapter)());
@ -148,5 +148,9 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
if (!omitTimers) {
appLoader.startTimers();
}
process.on('SIGINT', async () => {
await appLoader.unmount();
process.exit(0);
});
}
exports.startup = startup;

View File

@ -35,7 +35,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
allowedHeaders: ["oak-cxt"],
};
const io = new Server(httpServer, socketOption);
if (process.env.PM2_STATUS) {
if (process.env.pm_id || process.env.PM_ID) {
// pm2环境下要接入clusterAdapter
// https://socket.io/zh-CN/docs/v4/pm2/
io.adapter(createAdapter());
@ -170,4 +170,9 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
if (!omitTimers) {
appLoader.startTimers();
}
process.on('SIGINT', async () => {
await appLoader.unmount();
process.exit(0);
});
}