vicary
vicary6d ago

What is the proper way to write crons in a Fresh project?

Importing files calling Deno.cron() in the dependency tree of dev.ts would halt the build process during deno deploy. Is there a recommended way to add crons to a Fresh project?
4 Replies
marvinh.
marvinh.5d ago
halt the build process during deno deploy.
Do you get any output/logs in the terminal you can share?
vicary
vicaryOP5d ago
The build process quickly finished, it never exits because Deno.cron() is being ran thus hanging on to the event loop
marvinh.
marvinh.5d ago
Does it work when you guard the Deno.cron() call like this?
// Don't execute this during build
if (!Deno.args.includes("build")) {
Deno.cron(...)
}
// Don't execute this during build
if (!Deno.args.includes("build")) {
Deno.cron(...)
}
vicary
vicaryOP5d ago
yes that’s my current workaround after reading what dev.ts does, would be nice if fresh has a recommended way to do it

Did you find this page helpful?