uber-cron
v1.0.2
Published
Enhanced cron job scheduling with features you didn't know you need!
Downloads
2
Readme
UBER CRON
Enhanced cron job scheduling with features you didn't know you need! Based on cron: https://www.npmjs.com/package/cron
What has been added
The following functionality was implemented on top of the cron package:
- Control the number of executions that run in parallel using the
numParallelExecutions
paramter. - Configure whether a job should be stopped if an execution error occurs.
- Uses a provided logger object to log the following events:
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
Installation is straight forward with npm:
npm i uber-cron
Examples
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
> [email protected] 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!
*/
API Documentation
The full API documentation can be found here: https://decentro-gmbh.github.io/uber-cron/