Thursday 21 November 2019

Preserve setTimeout between process exits

I want to have a notification dispatched to some users at some point in the future, when a poll posted by them on my platform has ended. There can be multiple of those polls and multiple users can be indulged in them. So when the poll is created, I can use setTimeout to notify users at the expiry date of the poll that I obtain from the users. But the issue is that the node process often restarts because of frequent changes I do to the code, and I have to re build it.. Once the process is quit, setTimeout is also lost. So how do I preserve setTimeouts between process exits? In this case using setTimeout is obviously not the solution, but then what could be the way out of this problem? I could store this notification in some db and have a cron job run every so often, but is there any other, more elegant solution?

Submitted November 21, 2019 at 06:28PM by abhi12299

No comments:

Post a Comment