chore: launchMode

This commit is contained in:
chenos 2025-04-22 09:53:34 +08:00
parent 120aa3420c
commit bebb875694

View File

@ -48,6 +48,7 @@ module.exports = (cli) => {
.option('-i, --instances [instances]')
.option('--db-sync')
.option('--quickstart')
.option('--launch-mode [launchMode]')
.allowUnknownOption()
.action(async (opts) => {
checkDBDialect();
@ -119,17 +120,27 @@ module.exports = (cli) => {
]);
process.exit();
} else {
run(
'pm2-runtime',
[
'start',
...instancesArgs,
`${APP_PACKAGE_ROOT}/lib/index.js`,
NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
'--',
...process.argv.slice(2),
].filter(Boolean),
);
const launchMode = opts.launchMode || process.env.APP_LAUNCH_MODE || 'pm2';
if (launchMode === 'pm2') {
run(
'pm2-runtime',
[
'start',
...instancesArgs,
`${APP_PACKAGE_ROOT}/lib/index.js`,
NODE_ARGS ? `--node-args="${NODE_ARGS}"` : undefined,
'--',
...process.argv.slice(2),
].filter(Boolean),
);
} else {
run(
'node',
[`${APP_PACKAGE_ROOT}/lib/index.js`, ...(NODE_ARGS || '').split(' '), ...process.argv.slice(2)].filter(
Boolean,
),
);
}
}
});
};