I'm having an issue where my job does not execute immediately after being created. I have already run npx payload jobs:run beforehand, but nothing happens when I create a new job. The only way to get it to execute is by running npx payload jobs:run again.
Is there a way to ensure that jobs execute automatically as soon as they are created, without manually running the command again? Any insights would be appreciated.
// when create job
const createdJob = await payload.jobs.queue({
task: 'instagramCrawler',
input: {},
})
// in handler
export const instagramCrawler = {
slug: 'instagramCrawler',
handler: async ({ req }) => {
try {
console.log('instagramCrawler running')
// ...
return {
output: posts,
}
} catch (error: any) {
console.error(error)
throw error
}
},
} as TaskConfig<'instagramCrawler'>