README
mission.scheduler
Getting Started
Prerequisites
Installing
Environment Variables
Create new CRON Job
import { Job, Queuable, QueueBase, QueueRepo, RedisOptions } from 'mission.scheduler';
const redisOptions: RedisOptions = { port: 6379, host: '127.0.0.1', password: '' }; //Move this config values to .env file or eenvironment variables.
@Queuable('FirstQueue', {
defaultJobOptions: { removeOnComplete: true, repeat: { cron: '*/5 * * * * *' } },
redis: redisOptions,
})
export class MyFirstJob implements QueueBase<any> {
public async run(job: Job<any>): Promise<any> {
console.log(job);
// Your batch job logic goes here.
return;
}
}
Then add the payload data to that queue.
// Use Default Job Option
QueueRepo.get('FirstQueue')
.add({ name: 'firstjob' })
.catch((err) => console.error(err));
// Override the Job Optoin
QueueRepo.get('FirstQueue')
.add({ name: 'firstjob' }, { repeat: { cron: '*/2 * * * * *' } })
.catch((err) => console.error(err));