Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

long_running_on_tick.js 533B

1234567891011121314151617181920
  1. const CronJob = require('../lib/cron.js').CronJob;
  2. let isRunning = false;
  3. console.log('Before job instantiation');
  4. const job = new CronJob('* * * * * *', function() {
  5. const d = new Date();
  6. console.log('Check every second:', d, ', isRunning: ', isRunning);
  7. if (!isRunning) {
  8. isRunning = true;
  9. setTimeout(function() {
  10. console.log('Long running onTick complete:', new Date());
  11. isRunning = false;
  12. }, 3000);
  13. console.log('setTimeout triggered:', new Date());
  14. }
  15. });
  16. console.log('After job instantiation');
  17. job.start();