docs: add troubleshooting for subscribers + scheduled jobs not working (#13762)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import NotRunning from "../_sections/scheduled-jobs/not-running.mdx"
|
||||
import NotRunningWorkerMode from "../_sections/scheduled-jobs/not-running-worker-mode.mdx"
|
||||
|
||||
export const metadata = {
|
||||
title: `Scheduled Job Not Running on Schedule`,
|
||||
@@ -6,4 +7,46 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
<NotRunning />
|
||||
This guide helps you troubleshoot issues when a scheduled job in your Medusa application is not running, or running at unexpected times.
|
||||
|
||||
## Confirm Job is Set Up Correctly
|
||||
|
||||
Make sure that the scheduled job is set up correctly in your Medusa application. Check the following:
|
||||
|
||||
1. The job is created under the `src/jobs` directory.
|
||||
2. The job exports an asynchronous function that performs the task. For example:
|
||||
|
||||
```ts title="src/jobs/hello-world.ts"
|
||||
import { MedusaContainer } from "@medusajs/framework/types"
|
||||
|
||||
export default async function greetingJob(container: MedusaContainer) {
|
||||
const logger = container.resolve("logger")
|
||||
|
||||
logger.info("Greeting!")
|
||||
}
|
||||
```
|
||||
|
||||
3. The job exports a `config` object that has the following properties:
|
||||
- `name`: A unique name for the job.
|
||||
- `schedule`: A string that holds a [cron expression](https://crontab.guru/) or an `interval` indicating the schedule to run the job.
|
||||
|
||||
For example:
|
||||
|
||||
```ts title="src/jobs/hello-world.ts"
|
||||
export const config = {
|
||||
name: "greeting-every-minute",
|
||||
schedule: "* * * * *",
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Job Not Running on Schedule
|
||||
|
||||
<NotRunning />
|
||||
|
||||
---
|
||||
|
||||
## Confirm Worker Mode is Set Up Correctly
|
||||
|
||||
<NotRunningWorkerMode />
|
||||
Reference in New Issue
Block a user