Scheduled jobs
You can easily define background jobs in your Directive that Atmo will run on a schedule. Schedules run a set of steps, exactly like a handler. Schedules can be set up with an initial state to provide input.
1
schedules:
2
- name: atmo-report
3
every:
4
hours: 1
5
state:
6
repo: suborbital/atmo
7
steps:
8
- fn: ghstars
9
10
- fn: send-report
11
with:
12
stargazers: ghstars
Copied!
As you can see, you can choose how often the job runs using the every clause. You can set seconds, minutes, hours, or days (and you can combine them for values such as 'every 1 hour and 15 minutes').
If you need to change a Runnable's behaviour to run in a schedule, you can check req::method() == "SCHED". This can be useful when using the same Runnable for both request handlers and schedules.
Setting the state clause will allow you to 'seed' the job with values, and that state will update after each step, just as with request handlers. See state for more details.
Any issues running schedules (such as Runnables returning errors or any failures to execute the Runnables) will be logged, but nothing else.
Last modified 6mo ago
Export as PDF
Copy link