0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Reconfigured clean-expired-comped job to execute during morning UTC

refs https://ghost.slack.com/archives/C04MSE4MKJT/p1675948815531779

- running at a fixed hh:mm every day means a platform with a large number
  of Ghost sites will get hammered with DB requests when they all start
  up
- this reconfigures the cron to run at a random minute and second
  between 0am and 5am, which gives a 6 hour window
This commit is contained in:
Daniel Lockyer 2023-02-09 15:45:19 +01:00 committed by Daniel Lockyer
parent 5b4abea56d
commit 49e9be4368

View file

@ -14,10 +14,12 @@ module.exports = {
) {
// use a random seconds value to avoid spikes to external APIs on the minute
const s = Math.floor(Math.random() * 60); // 0-59
const m = Math.floor(Math.random() * 60); // 0-59
const h = Math.floor(Math.random() * 6); // 0-5
// Run everyday at 12:05:X AM to clean all expired complimentary subscriptions
// Run everyday at {0-5}:XX:XX AM to clean all expired complimentary subscriptions
jobsService.addJob({
at: `${s} 5 0 * * *`,
at: `${s} ${m} ${h} * * *`,
job: path.resolve(__dirname, 'clean-expired-comped.js'),
name: 'clean-expired-comped'
});