0

I am trying to understand how node-cron by kelektiv works.

Specifically, if your node app crashes, how does it remember the dates that you scheduled for an event? Does it store the jobs in a database somewhere or a somewhere locally on the machine?

Any recommended reading resources or an explanation will be very helpful.

Thank you in advance for your answer.

KJ Ang
  • 305
  • 3
  • 9
  • What makes you think it does store them? Or that it recovers after a crash? The whole module is only [one file here](https://github.com/kelektiv/node-cron/blob/master/lib/cron.js) and I don't see anywhere that anything is saved. – jfriend00 Apr 30 '20 at 04:01

1 Answers1

0

See this code: https://github.com/kelektiv/node-cron/blob/master/lib/cron.js They are using methods to calculate when to send next by sendAt, how much time is left before sending next by getTimeout and then they are simply putting a setTimeout based on that in start. It's a nice piece of code and I'll suggest you to check it out, it's very simple and written in very understandable way. And no it doesn't stores the next time in Database, it's just setTimeout

MiKr13
  • 1,297
  • 13
  • 20