fix(medusa): start cluster (#13599)
This commit is contained in:
1 parent
c3ae529b40
commit
3960c80e9f
2 files changed
+14
-9
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): start cluster
|
||||||
@@ -146,13 +146,13 @@ async function start(args: {
|
|||||||
}) {
|
}) {
|
||||||
const { port = 9000, host, directory, types } = 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) {
|
async function internalStart(generateTypes: boolean) {
|
||||||
track("CLI_START")
|
track("CLI_START")
|
||||||
|
|
||||||
|
const container = await initializeContainer(directory, {
|
||||||
|
skipDbConnection: true,
|
||||||
|
})
|
||||||
|
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||||
await registerInstrumentation(directory)
|
await registerInstrumentation(directory)
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
@@ -270,13 +270,13 @@ async function start(args: {
|
|||||||
const killMainProccess = () => process.exit(0)
|
const killMainProccess = () => process.exit(0)
|
||||||
const gracefulShutDown = () => {
|
const gracefulShutDown = () => {
|
||||||
isShuttingDown = true
|
isShuttingDown = true
|
||||||
for (const id of Object.keys(cluster.workers ?? {})) {
|
|
||||||
cluster.workers?.[id]?.kill("SIGTERM")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let index = 0; index < numCPUs; index++) {
|
for (let index = 0; index < numCPUs; index++) {
|
||||||
cluster.fork().send({ index })
|
const worker = cluster.fork()
|
||||||
|
worker.on("online", () => {
|
||||||
|
worker.send({ index })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster.on("exit", () => {
|
cluster.on("exit", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user