jhonderson / gone-man-switch

Gone Man’s Switch
GNU General Public License v3.0
74 stars 2 forks source link

Question About Server Downtime #7

Closed EyeOfEnigma closed 3 months ago

EyeOfEnigma commented 3 months ago

Hello,

Just curious how this application handles server downtime.

Hypothetically if I had a message with a check-in of 30 days, and a deliver if no response in 10 days. What would happen if say the server went down for longer than 40 days? When the server came back online would the app see that I have not checked in, and the delivery date has passed and then immediately send the message? if so, would there be a way to prevent the send?

Or will it notice I have not checked in 30 days and send me the check-in email, then the timer waits 10 days from that point? That would of course bring into question what happens if the server goes down within those 10 days and comes back online after the 10 days? Will the message just be sent once back online?

Thanks for any clarity.

jhonderson commented 3 months ago

Hello,

A message is delivered only if a check-in notification was sent and hasn't be responded for the amount of days specified, in your example for 10 days. So, for the first question, once the server come back online after 40 days it will send a check-in notification. If you are familiar with SQL, see the query to get the messages ready to be delivered here.

For your second scenario (check-in notification is sent, then the server goes down and comes back online after 10 days), the message will be delivered as soon as the service goes back online and the messages job cron kicks-in.

Both jobs, check-in notification sender and messages sender are by default executed daily at 5:00 pm UTC and 6:00 pm UTC, but you can change that behaviour setting up CHECKIN_NOTIFICATIONS_JOB_CRON or MESSAGES_JOB_CRON, and sends stuff based on that :)

In general, the server downtime is not taken into account by GMS business logic, it is just aware of what time is today, what was the last time a user was active, and the time a notification was sent.

Hope that helps.

EyeOfEnigma commented 3 months ago

Awesome, that is perfect and well designed. Thank you for clarity and for your amazing work!