N
Nuxt3mo ago
takburger

How to run nitro task on cloudflare ?

I have deployed a site on cloudflare using nuxt hub. I have on it a task, specified to run every hour. However I realized that task isn't triggered on production on cloudflare. Here is my config on nuxt.config.ts :
nitro: {
experimental: {
// Enable Server API documentation within NuxtHub
openAPI: true,
tasks: true,
},
scheduledTasks: {
"0 * * * *": "news:update",
},
},
nitro: {
experimental: {
// Enable Server API documentation within NuxtHub
openAPI: true,
tasks: true,
},
scheduledTasks: {
"0 * * * *": "news:update",
},
},
4 Replies
nicgene
nicgene3mo ago
If you're using a wrangler.toml, make sure the [triggers] section is defined. Also, check if the task was created in the Workers dashboard. The example in the documentation uses an array: '* * * * *': ['cms:update']. https://nitro.unjs.io/guide/tasks#scheduled-tasks I'm not familiar with Nuxt Hub myself.
takburger
takburger3mo ago
Thank you ! I totally missed that part. Do you have more experience on using triggers with nitro and wrangler.toml ? I added the trigger section as follow : [triggers] crons = [ "0 * * * *"] But it didn't do the trick, probably because it doesn't refer to the specified task, but I don't know the syntax.
nicgene
nicgene3mo ago
If I remember correctly the cron times just need to match up. If there aren't any errors during build the schedule: ... should print out.
takburger
takburger3mo ago
Thanks for the feedback, didn't have any schedule:in the build log. I set up a cron worker on the side to trigger a webhook to replace the task for now.
Want results from more Discord servers?
Add your server