Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Feb 8, 2024
1 parent d7f794f commit 2e54f40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/Jobs/ExampleJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Every } from '@stacksjs/types'
import { log } from '@stacksjs/cli'

export default new Job({
name: 'Send Welcome Email', // optional, defaults to the file name
name: 'Example Job', // optional, defaults to the file name
description: 'A demo cron job that runs every minute', // optional
queue: 'default', // optional, defaults to 'default'
tries: 3, // optional, defaults to 3, in case of failures
backoff: 3, // optional, defaults to 3-second delays between retries
rate: Every.Minute, // optional, '* * * * *' in cron syntax (overwrites the Scheduler's definition)
Expand Down
11 changes: 11 additions & 0 deletions app/Jobs/ExampleJobTwo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Job } from '@stacksjs/queue'
import { Every } from '@stacksjs/types'
import { log } from '@stacksjs/cli'

export default new Job({
rate: Every.TwoMinutes, // optional, '* * * * *' in cron syntax (overwrites the Scheduler's definition)
handle: () => { // action: 'SendWelcomeEmail', // instead of handle, you may target an action or `action: () => {`
log.info('This cron job log this message every two minutes')
log.info('Please note, any job may also be dispatched individually, or scheduled via ./app/Schedule')
},
})
11 changes: 8 additions & 3 deletions storage/framework/core/types/src/cron-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ export enum Every {
// TenSeconds = '*/10 * * * * *',
// ThirtySeconds = '*/30 * * * * *',
Minute = '* * * * *',
TwoMinutes = '*/2 * * * *',
FiveMinutes = '*/5 * * * *',
TenMinutes = '*/10 * * * *',
FifteenMinutes = '*/15 * * * *',
ThirtyMinutes = '*/30 * * * *',
Hour = '0 * * * *',
HalfHour = '0,30 * * * *',
Day = '0 0 * * *',
Month = '0 0 1 * *',
Week = '0 0 * * 0',
Weekday = '0 0 * * 1-5',
Weekend = '0 0 * * 0,6',
Month = '0 0 1 * *',
Year = '0 0 1 1 *',
FifthMinute = '*/5 * * * *',
TenthMinute = '*/10 * * * *',
}

0 comments on commit 2e54f40

Please sign in to comment.