No, it is just a function which is supposed to run on its own when container starts, it is a cron co

No, it is just a function which is supposed to run on its own when container starts, it is a cron container, so it does not respond back anything,
import { Container, getContainer } from "@cloudflare/containers";

export class dummy extends Container {
  constructor(state, env) {
    super(state, env);
    // Set envVars in constructor
    this.envVars = {
      NAME: env.name,
    };
  }
  sleepAfter = "30m";
  async onStart() {
    console.log("Container started");
  }
  enableInternet = true;
  onStop() {
    console.log("Container shut down");
  }
  onError(error) {
    console.log("Error:", error);
  }

}
export default {
  async fetch(request, env, ctx) {
    // Trigger Durable Object
    console.log("Manual trigger → starting container");
    const container = getContainer(env.DUMMY);
    await container.start({
      startOptions: {
        envVars: {
          // You can pass dynamic values here
          MANUAL_TRIGGERED_AT: new Date().toISOString(),
        },
      },
    });
    return new Response("Container manually triggered and executed", {
      status: 200,
    });
  },
  async scheduled(controller, env, ctx) {
    console.log("Cron triggered");
    const container = getContainer(env.DUMMY);
    await container.start({
      startOptions: {
        envVars: {
          CRON_TRIGGERED_AT: new Date().toISOString(),
        },
      },
    });
  },
};
For reference this is my worker code, and my container is a python function.
Was this page helpful?