Skip to content

Commit

Permalink
Improved maxDuration comments in the templates
Browse files Browse the repository at this point in the history
  • Loading branch information
D-K-P committed Nov 7, 2024
1 parent 82ebfc7 commit 71808fa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/cli-v3/templates/examples/schedule.mjs.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { logger, schedules, wait } from "@trigger.dev/sdk/v3";

export const firstScheduledTask = schedules.task({
id: "first-scheduled-task",
//every hour
// Every hour
cron: "0 * * * *",
maxDuration: 300, // 5 minutes
// Set an optional maxDuration to prevent tasks from running indefinitely
maxDuration: 300, // Stop executing after 300 secs (5 mins) of compute
run: async (payload, { ctx }) => {
// The payload contains the last run timestamp that you can use to check if this is the first run
// And calculate the time since the last run
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-v3/templates/examples/schedule.ts.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { logger, schedules, wait } from "@trigger.dev/sdk/v3";

export const firstScheduledTask = schedules.task({
id: "first-scheduled-task",
//every hour
// Every hour
cron: "0 * * * *",
maxDuration: 300, // 5 minutes
// Set an optional maxDuration to prevent tasks from running indefinitely
maxDuration: 300, // Stop executing after 300 secs (5 mins) of compute
run: async (payload, { ctx }) => {
// The payload contains the last run timestamp that you can use to check if this is the first run
// And calculate the time since the last run
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-v3/templates/examples/simple.mjs.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { logger, task, wait } from "@trigger.dev/sdk/v3";

export const helloWorldTask = task({
id: "hello-world",
maxDuration: 300, // 5 minutes
// Set an optional maxDuration to prevent tasks from running indefinitely
maxDuration: 300, // Stop executing after 300 secs (5 mins) of compute
run: async (payload, { ctx }) => {
logger.log("Hello, world!", { payload, ctx });

Expand Down
3 changes: 2 additions & 1 deletion packages/cli-v3/templates/examples/simple.ts.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { logger, task, wait } from "@trigger.dev/sdk/v3";

export const helloWorldTask = task({
id: "hello-world",
maxDuration: 300, // 5 minutes
// Set an optional maxDuration to prevent tasks from running indefinitely
maxDuration: 300, // Stop executing after 300 secs (5 mins) of compute
run: async (payload: any, { ctx }) => {
logger.log("Hello, world!", { payload, ctx });

Expand Down

0 comments on commit 71808fa

Please sign in to comment.