Enhanced cron job scheduling with features you didn't know you need! Based on cron: https://www.npmjs.com/package/cron
The following functionality was implemented on top of the cron package:
numParallelExecutions
paramter.JOB_STARTED
: A job has been startedJOB_STOPPED
: A job has been stopppedJOB_EXECUTION_STARTING
: The onTick method of a job is about to be executedJOB_EXECUTION_FINISHED
: The onTick method of a job finished successfullyJOB_EXECUTION_ERROR
: An error occured during the execution of the job's onTick methodREACHED_MAX_PARALLEL_EXECUTIONS
: The maximum number of parallel job executions has been reached (the request to start another job execution has been ignored)Installation is straight forward with npm:
npm i uber-cron
const cronJob = new UberCron('simpleJob', {
cronTime: '*/1 * * * * *',
start: true,
logger: null,
onTick: () => console.log(`Job being executed right now!`),
});
setTimeout(() => cronJob.stop(), 3500);
/**
OUTPUT:
root@uber-cron:/app# npm run start
> uber-cron@1.0.0 start /app
> ts-node --project tsconfig.json example/index.ts
Job being executed right now!
Job being executed right now!
Job being executed right now!
*/
The full API documentation can be found here: https://decentro-gmbh.github.io/uber-cron/