feat: node args in pm2 runtime (#1774)

This commit is contained in:
ChengLei Shao 2023-04-26 20:54:38 +08:00 committed by GitHub
parent e45b3ce95c
commit 76527465f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ const chalk = require('chalk');
* @param {Command} cli * @param {Command} cli
*/ */
module.exports = (cli) => { module.exports = (cli) => {
const { APP_PACKAGE_ROOT } = process.env; const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env;
cli cli
.command('start') .command('start')
.option('-p, --port [port]') .option('-p, --port [port]')
@ -51,12 +51,16 @@ module.exports = (cli) => {
if (opts.daemon) { if (opts.daemon) {
run('pm2', ['start', `packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, '--', ...process.argv.slice(2)]); run('pm2', ['start', `packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, '--', ...process.argv.slice(2)]);
} else { } else {
run('pm2-runtime', [ run(
'start', 'pm2-runtime',
`packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, [
'--', 'start',
...process.argv.slice(2), `packages/${APP_PACKAGE_ROOT}/server/lib/index.js`,
]); NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
'--',
...process.argv.slice(2),
].filter(Boolean),
);
} }
}); });
}; };