The documentation shows how to use JobScheduler.schedule() but doesn't explain where to call it or which AdonisJS environment to use.
Should scheduled jobs be set up in a preload file? If so, which environment?
Current Approach (uncertain if correct)
// start/scheduler.ts
import app from '@adonisjs/core/services/app'
import { JobScheduler } from '@nemoventures/adonis-jobs'
import MyJob from '#jobs/my_job'
app.ready(async () => {
await JobScheduler.schedule({
key: 'my-scheduled-job',
job: MyJob,
data: {},
repeat: { pattern: '0 * * * *' },
})
})
// adonisrc.ts
preloads: [
{
file: () => import('#start/scheduler'),
environment: ['console'], // ← Is this correct?
},
]
What needs clarification
- Is using a preload file the recommended approach?
- Should environment: ['console'] be used, or no environment restriction?
- Is JobScheduler.schedule() idempotent (safe to call multiple times)?
- In multi-process deployments (separate web/worker containers), where should schedules be registered?
Suggested addition
A "Scheduling Jobs" guide section covering the recommended setup pattern and environment configuration would be very helpful.
The documentation shows how to use JobScheduler.schedule() but doesn't explain where to call it or which AdonisJS environment to use.
Should scheduled jobs be set up in a preload file? If so, which environment?
Current Approach (uncertain if correct)
What needs clarification
Suggested addition
A "Scheduling Jobs" guide section covering the recommended setup pattern and environment configuration would be very helpful.