Help setting up an Astro app alongside a cron trigger

Hi there! I have an astro app that I am deploying and I want to setup a cron trigger to run a different function. Is there a way to do this without having to setup a separate wrangler config and worker app? I have considered solving this with a monorepo and separate configs for astro and the scheduled function, but I'd prefer to keep it all together if possible. When referencing the docs for the @astrojs/cloudflare adapter (https://docs.astro.build/en/guides/integrations-guide/cloudflare/#creating-a-custom-cloudflare-worker-entry-file), the following code doesn't trigger the scheduled worker.
export function createExports(manifest: SSRManifest) {
const app = new App(manifest);
return {
default: {
async fetch(request, env, ctx) {
await env.MY_QUEUE.send("log");
return handle(manifest, app, request, env, ctx);
},
async scheduled(batch, _env) {
// This function never runs.
await myCronFunctionHandler();
}
} satisfies ExportedHandler<Env>
}
}
export function createExports(manifest: SSRManifest) {
const app = new App(manifest);
return {
default: {
async fetch(request, env, ctx) {
await env.MY_QUEUE.send("log");
return handle(manifest, app, request, env, ctx);
},
async scheduled(batch, _env) {
// This function never runs.
await myCronFunctionHandler();
}
} satisfies ExportedHandler<Env>
}
}
Docs
@astrojs/cloudflare
Learn how to use the @astrojs/cloudflare adapter to deploy your Astro project.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?