Piattaforma ITI TECHNOLOGY: monorepo, Medusa, API, sito, area riservata e deploy
Deploy stack su Proxmox / deploy (push) Failing after 3s
Deploy stack su Proxmox / deploy (push) Failing after 3s
Monorepo npm con apps/public (Angular SSR), apps/private (Angular SPA), apps/api (Fastify), packages/shared e packages/styles; Medusa 2.21 in medusa/; infrastruttura Docker (Postgres PostGIS+pgvector, Redis, Caddy, backup) e workflow Gitea Actions per il deploy via SSH a ogni push su master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jQyT6dR9czzGwqb7FkG6u
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# Custom scheduled jobs
|
||||
|
||||
A scheduled job is a function executed at a specified interval of time in the background of your Medusa application.
|
||||
|
||||
> Learn more about scheduled jobs in [this documentation](https://docs.medusajs.com/learn/fundamentals/scheduled-jobs).
|
||||
|
||||
A scheduled job is created in a TypeScript or JavaScript file under the `src/jobs` directory.
|
||||
|
||||
For example, create the file `src/jobs/hello-world.ts` with the following content:
|
||||
|
||||
```ts
|
||||
import {
|
||||
MedusaContainer
|
||||
} from "@medusajs/framework/types";
|
||||
|
||||
export default async function myCustomJob(container: MedusaContainer) {
|
||||
const productService = container.resolve("product")
|
||||
|
||||
const products = await productService.listAndCountProducts();
|
||||
|
||||
// Do something with the products
|
||||
}
|
||||
|
||||
export const config = {
|
||||
name: "daily-product-report",
|
||||
schedule: "0 0 * * *", // Every day at midnight
|
||||
};
|
||||
```
|
||||
|
||||
A scheduled job file must export:
|
||||
|
||||
- The function to be executed whenever it’s time to run the scheduled job.
|
||||
- A configuration object defining the job. It has three properties:
|
||||
- `name`: a unique name for the job.
|
||||
- `schedule`: a [cron expression](https://crontab.guru/).
|
||||
- `numberOfExecutions`: an optional integer, specifying how many times the job will execute before being removed
|
||||
|
||||
The `handler` is a function that accepts one parameter, `container`, which is a `MedusaContainer` instance used to resolve services.
|
||||
Reference in New Issue
Block a user