From 689a7935934d2e6adec3f60820c8b42b683930b9 Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 9 Jul 2022 14:45:47 +0800 Subject: [PATCH] feat(cli): add daemon option to start command --- packages/core/cli/src/commands/start.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/cli/src/commands/start.js b/packages/core/cli/src/commands/start.js index 2e6afc5fb..63653a5e3 100644 --- a/packages/core/cli/src/commands/start.js +++ b/packages/core/cli/src/commands/start.js @@ -13,6 +13,7 @@ module.exports = (cli) => { cli .command('start') .option('-p, --port [port]') + .option('-d, --daemon') .option('--db-sync') .allowUnknownOption() .action(async (opts) => { @@ -48,6 +49,15 @@ module.exports = (cli) => { if (opts.dbSync) { await run('node', [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, 'db:sync']); } - run('pm2-runtime', ['start', `packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, '--', ...process.argv.slice(2)]); + if (opts.daemon) { + run('pm2', ['start', `packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, '--', ...process.argv.slice(2)]); + } else { + run('pm2-runtime', [ + 'start', + `packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, + '--', + ...process.argv.slice(2), + ]); + } }); };