feat(medusa): Improve add line item to cart perf and transaction management + clustering start command (#5701)

This commit is contained in:
Adrien de Peretti
2023-12-06 08:53:35 +01:00
committed by GitHub
parent a458cd144d
commit 6975eacb33
14 changed files with 341 additions and 147 deletions

View File

@@ -1,13 +1,13 @@
import path from "path"
import resolveCwd from "resolve-cwd"
import { sync as existsSync } from "fs-exists-cached"
import { setTelemetryEnabled } from "medusa-telemetry"
import path from "path"
import resolveCwd from "resolve-cwd"
import { getLocalMedusaVersion } from "./util/version"
import { didYouMean } from "./did-you-mean"
import { getLocalMedusaVersion } from "./util/version"
import reporter from "./reporter"
import { newStarter } from "./commands/new"
import reporter from "./reporter"
const yargs = require(`yargs`)
@@ -233,6 +233,42 @@ function buildLocalCommands(cli, isLocalProject) {
})
),
})
.command({
command: `start-cluster`,
desc: `Start development server in cluster mode (beta).`,
builder: (_) =>
_.option(`H`, {
alias: `host`,
type: `string`,
default: defaultHost,
describe: `Set host. Defaults to ${defaultHost}`,
})
.option(`p`, {
alias: `port`,
type: `string`,
default: process.env.PORT || defaultPort,
describe: process.env.PORT
? `Set port. Defaults to ${process.env.PORT} (set by env.PORT) (otherwise defaults ${defaultPort})`
: `Set port. Defaults to ${defaultPort}`,
})
.option(`c`, {
alias: `cpus`,
type: `number`,
default: process.env.CPUS,
describe:
"Set number of cpus to use. Defaults to max number of cpus available on the system (set by env.CPUS)",
}),
handler: handlerP(
getCommandHandler(`start-cluster`, (args, cmd) => {
process.env.NODE_ENV = process.env.NODE_ENV || `development`
cmd(args)
// Return an empty promise to prevent handlerP from exiting early.
// The development server shouldn't ever exit until the user directly
// kills it so this is fine.
return new Promise((resolve) => {})
})
),
})
.command({
command: `user`,
desc: `Create a user`,