fix(medusa): start cluster (#13599)

This commit is contained in:
Carlos R. L. Rodrigues
2025-09-25 16:07:22 -03:00
committed by GitHub
parent c3ae529b40
commit 3960c80e9f
2 changed files with 14 additions and 9 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---
fix(medusa): start cluster

View File

@@ -146,13 +146,13 @@ async function start(args: {
}) {
const { port = 9000, host, directory, types } = args
const container = await initializeContainer(directory, {
skipDbConnection: true,
})
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
async function internalStart(generateTypes: boolean) {
track("CLI_START")
const container = await initializeContainer(directory, {
skipDbConnection: true,
})
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
await registerInstrumentation(directory)
const app = express()
@@ -270,13 +270,13 @@ async function start(args: {
const killMainProccess = () => process.exit(0)
const gracefulShutDown = () => {
isShuttingDown = true
for (const id of Object.keys(cluster.workers ?? {})) {
cluster.workers?.[id]?.kill("SIGTERM")
}
}
for (let index = 0; index < numCPUs; index++) {
cluster.fork().send({ index })
const worker = cluster.fork()
worker.on("online", () => {
worker.send({ index })
})
}
cluster.on("exit", () => {