You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using go-cron to work, multiple services are started at the same time, and multiple cron tasks will be executed at the same time? What can be done to ensure that the cron task is only executed once?
#476
Open
Jayleonc opened this issue
Dec 29, 2022
· 2 comments
Hi! When using go-cron to work, multiple services are started at the same time, and multiple cron tasks will be executed at the same time? What can be done to ensure that the cron task is only executed once?
The text was updated successfully, but these errors were encountered:
best way would be to use some sort of shared cache (like redis) to store the state for a period of time. For example, cron A from service 1 will set a key "cron_a_running" with a certain lifetime. The cron function should successfully finish (and remove the key) OR fail (and the key will live until expiration or until manually remove). The same cron A running from service 2 will check said key in redis and skip an execution if the key is there.
not a perfect solution - but this is just a simple cron manager and while I'm not part of the project, a system of clustering feels out of scope.
Hi! When using go-cron to work, multiple services are started at the same time, and multiple cron tasks will be executed at the same time? What can be done to ensure that the cron task is only executed once?
The text was updated successfully, but these errors were encountered: