Skip to content

Scheduler Updates

Choose a tag to compare

@ganeshsacharya ganeshsacharya released this 29 Mar 11:17
· 16 commits to main since this release

Updates to execute cron jobs in your Njs2 Projects

A new condition has been added to the default handler function which can now read the cron tasks and execute them based on the cron pattern mentioned in config.json

Documentation can be found in the below link:
cron

e.g.: say you want to execute a piece of code every 'n' minutes,

  1. Make a new entry with the required cron pattern in the config.json file
  2. Ask the DevOps team to make a AWS EventBridge Rule to have an EVERY MINUTE call to your Lambda function with just requestType = "cron" as the param
  3. Njs2 Framework should now check each cron entry in your Lambda Code > config.json file and if the cron pattern matches the current minute it shall execute the respective task

What if i want to upgrade my existing project to use this @njs2/base version?

  1. copy the cron.js, mCron.js files from HERE to the root of your project
  2. update your config.json as per this documentation
  3. install the latest @njs2/base version using: npm i @njs2/base@latest or npm i @njs2/base@2.2.0
  4. run the project locally and configure your crontab as per this documentation (unix based systems only!)