-
-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathschedule.js
More file actions
26 lines (18 loc) · 611 Bytes
/
Copy pathschedule.js
File metadata and controls
26 lines (18 loc) · 611 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { PgBoss } from '../dist/index.mjs'
import * as helper from '../test/testHelper.js'
async function schedule () {
const boss = new PgBoss(helper.getConnectionString())
boss.on('error', console.error)
await boss.start()
const queue = 'scheduled-queue'
await boss.createQueue(queue)
await boss.schedule(queue, '*/2 * * * *', { arg1: 'schedule me' })
await boss.work(queue, async ([job]) => {
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)} on ${new Date().toISOString()}`)
})
}
schedule()
.catch(err => {
console.log(err)
process.exit(1)
})