Skip to content

Commit

Permalink
Add scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Dec 13, 2023
1 parent 2981d5b commit 90b244e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sst.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SSTConfig } from "sst";
import { api } from "./stacks/MyStack";
import { scheduler } from "./stacks/Scheduler";

export default {
config(_input) {
Expand All @@ -10,5 +11,6 @@ export default {
},
stacks(app) {
app.stack(api);
app.stack(scheduler);
},
} satisfies SSTConfig;
11 changes: 11 additions & 0 deletions stacks/Scheduler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Cron, StackContext } from "sst/constructs";

const cronScheduler = `0/60 12-18 ? * MON-FRI *`;

export const scheduler = ({ stack }: StackContext) => {
new Cron(stack, "cron", {
schedule: `cron(${cronScheduler})`,
job: "packages/functions/src/datasets.updater",
enabled: stack.stage === "prod",
});
};

0 comments on commit 90b244e

Please sign in to comment.