mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Moved update check scheduling logic out of boot.js
refs https://github.com/TryGhost/Team/issues/754 - This is a minor cleanup. There should be no logic in the boot.js file other than calling services to "initialize themselves"
This commit is contained in:
parent
90cc801394
commit
0d0e09f173
15
core/boot.js
15
core/boot.js
@ -5,6 +5,8 @@
|
||||
// - As we manage to break the codebase down into distinct components for e.g. the frontend, their boot logic can be offloaded to them
|
||||
// - app.js is separate as the first example of each component having it's own app.js file colocated with it, instead of inside of server/web
|
||||
|
||||
const updateCheck = require('./server/update-check');
|
||||
|
||||
// IMPORTANT: The only global requires here should be overrides + debug so we can monitor timings with DEBUG=ghost:boot* node ghost
|
||||
require('./server/overrides');
|
||||
const debug = require('@tryghost/debug')('boot');
|
||||
@ -207,18 +209,7 @@ async function initBackgroundServices({config}) {
|
||||
const themeService = require('./server/services/themes');
|
||||
themeService.loadInactiveThemes();
|
||||
|
||||
const jobsService = require('./server/services/jobs');
|
||||
|
||||
// use a random seconds/minutes/hours value to avoid spikes to the update service API
|
||||
const s = Math.floor(Math.random() * 60); // 0-59
|
||||
const m = Math.floor(Math.random() * 60); // 0-59
|
||||
const h = Math.floor(Math.random() * 24); // 0-23
|
||||
|
||||
jobsService.addJob({
|
||||
at: `${s} ${m} ${h} * * *`, // Every day
|
||||
job: require('path').resolve(__dirname, 'server', 'run-update-check.js'),
|
||||
name: 'update-check'
|
||||
});
|
||||
updateCheck.scheduleRecurringJobs();
|
||||
|
||||
debug('End: initBackgroundServices');
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ const api = require('./api').v2;
|
||||
const GhostMailer = require('./services/mail').GhostMailer;
|
||||
const config = require('../shared/config');
|
||||
const urlUtils = require('./../shared/url-utils');
|
||||
const jobsService = require('./services/jobs');
|
||||
|
||||
const i18n = require('../shared/i18n');
|
||||
const logging = require('@tryghost/logging');
|
||||
@ -59,3 +60,16 @@ module.exports = () => {
|
||||
|
||||
updateChecker.check();
|
||||
};
|
||||
|
||||
module.exports.scheduleRecurringJobs = () => {
|
||||
// use a random seconds/minutes/hours value to avoid spikes to the update service API
|
||||
const s = Math.floor(Math.random() * 60); // 0-59
|
||||
const m = Math.floor(Math.random() * 60); // 0-59
|
||||
const h = Math.floor(Math.random() * 24); // 0-23
|
||||
|
||||
jobsService.addJob({
|
||||
at: `${s} ${m} ${h} * * *`, // Every day
|
||||
job: require('path').resolve(__dirname, 'run-update-check.js'),
|
||||
name: 'update-check'
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user