Why does the autoRun does not work?
I can queue my Job manually using payload.jobs.queue() and then also execute if via the the /payload-jobs/run route.
But it does not schedules itself, although i enabled the shouldAutoRun function.
Any Ideas what i am doing wrong?
tasks: [
{
slug: 'updateAccountTrafficStatistics',
handler: updateAccountTrafficStatistics,
onSuccess: async () => {
console.log('✅ TASK:: updateAccountTrafficStatistics :: SUCCESS')
},
onFail: async () => {
console.log('❌ TASK:: updateAccountTrafficStatistics :: FAILURE')
},
} as TaskConfig<'updateAccountTrafficStatistics'>,
],
workflows: [
{
slug: 'updateAccountTrafficStatisticsWorkflow',
queue: 'every-hour-at-30-minutes',
handler: updateAccountTrafficStatisticWorkflow,
} as WorkflowConfig<'updateAccountTrafficStatisticsWorkflow'>,
],
autoRun: [
{
cron: '30 * * * *', // every 1 hour at 30 minutes past the hour
limit: 100, // limit jobs to process each run
queue: 'every-hour-at-30-minutes', // name of the queue
},
],
shouldAutoRun: async (payload) => {
return true
},
are you on vercel/serverless? if so, you may need to start automatically ... i usually do this wrapped by
waitUntilfrom
@vercel/functionsbut personally i do kinda hope this is supported automatically in payload eventually
No. Im working locally inside my docker container
The docs are way too vague and “autoRun” is deceptively named. It’s up to you to ping the queue. For your use case you can just set up a cron job in docker to hit the api route every X minutes
I found a workarround, where you queue your workflows in the onInit function and then you requeue it after each workflow execution. This works, but does not feel ideal.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.