chore(): Run some commands in server mode only (#14202)
* chore(): Run some commands in server mode only * Create orange-timers-lay.md * chore(): Run some commands in server mode only * chore(): Run some commands in server mode only * chore(): Run some commands in server mode only
This commit is contained in:
committed by
GitHub
parent
008f5bb47d
commit
24c469d217
5
.changeset/orange-timers-lay.md
Normal file
5
.changeset/orange-timers-lay.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
chore(): Run some commands in server mode only
|
||||
@@ -128,6 +128,7 @@ const main = async function ({
|
||||
executeSafeLinks,
|
||||
concurrency,
|
||||
}) {
|
||||
process.env.MEDUSA_WORKER_MODE = "server"
|
||||
const container = await initializeContainer(directory)
|
||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import { ensureDbExists } from "../utils"
|
||||
const TERMINAL_SIZE = process.stdout.columns
|
||||
|
||||
const main = async function ({ directory, modules }) {
|
||||
process.env.MEDUSA_WORKER_MODE = "server"
|
||||
|
||||
const container = await initializeContainer(directory)
|
||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ const main = async function ({
|
||||
directory: string
|
||||
container?: MedusaContainer
|
||||
}) {
|
||||
process.env.MEDUSA_WORKER_MODE = "server"
|
||||
const container = await initializeContainer(directory)
|
||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ type Options = {
|
||||
}
|
||||
|
||||
export default async function exec({ file, args }: Options) {
|
||||
process.env.MEDUSA_WORKER_MODE = "server"
|
||||
|
||||
const container = await initializeContainer(process.cwd(), {
|
||||
skipDbConnection: true,
|
||||
})
|
||||
@@ -41,8 +43,6 @@ export default async function exec({ file, args }: Options) {
|
||||
throw new Error(`File doesn't default export a function to execute.`)
|
||||
}
|
||||
|
||||
process.env.MEDUSA_WORKER_MODE = "server"
|
||||
|
||||
const { container } = await loaders({
|
||||
directory,
|
||||
expressApp: app,
|
||||
|
||||
@@ -14,11 +14,7 @@ export default async function ({
|
||||
track("CLI_USER", { with_id: !!id })
|
||||
const app = express()
|
||||
try {
|
||||
/**
|
||||
* Enabling worker mode to prevent discovering/loading
|
||||
* of API routes from the starter kit
|
||||
*/
|
||||
process.env.MEDUSA_WORKER_MODE = "worker"
|
||||
process.env.MEDUSA_WORKER_MODE = "server"
|
||||
|
||||
const { container } = await loaders({
|
||||
directory,
|
||||
|
||||
@@ -91,14 +91,6 @@ async function loadEntrypoints(
|
||||
ContainerRegistrationKeys.CONFIG_MODULE
|
||||
)
|
||||
|
||||
// Subscribers should be loaded no matter the worker mode, simply they will never handle anything
|
||||
// since worker/shared instances only will have a running worker to process events.
|
||||
await subscribersLoader(plugins, container)
|
||||
|
||||
if (shouldLoadBackgroundProcessors(configModule)) {
|
||||
await jobsLoader(plugins, container)
|
||||
}
|
||||
|
||||
if (isWorkerMode(configModule)) {
|
||||
return async () => {}
|
||||
}
|
||||
@@ -202,6 +194,14 @@ export default async ({
|
||||
const workflowLoader = new WorkflowLoader(workflowsSourcePaths, container)
|
||||
await workflowLoader.load()
|
||||
|
||||
// Subscribers should be loaded no matter the worker mode, simply they will never handle anything
|
||||
// since worker/shared instances only will have a running worker to process events.
|
||||
await subscribersLoader(plugins, container)
|
||||
|
||||
if (shouldLoadBackgroundProcessors(configModule)) {
|
||||
await jobsLoader(plugins, container)
|
||||
}
|
||||
|
||||
const entrypointsShutdown = skipLoadingEntryPoints
|
||||
? () => {}
|
||||
: await loadEntrypoints(plugins, container, expressApp, rootDirectory)
|
||||
|
||||
Reference in New Issue
Block a user