From 0223291c45809d4a9dcc2be9ac4aa9406610a89c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Nov 2020 14:55:18 +0100 Subject: [PATCH] Delay video views scheduled job To not overload the federation --- server/initializers/constants.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 97fd1bdc1..0bb251043 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -1,24 +1,24 @@ +import { CronRepeatOptions, EveryRepeatOptions } from 'bull' +import { randomBytes, randomInt } from 'crypto' +import { invert } from 'lodash' import { join } from 'path' -import { randomBytes } from 'crypto' -import { ActivityPubActorType } from '../../shared/models/activitypub' -import { FollowState } from '../../shared/models/actors' import { AbuseState, + JobType, VideoImportState, VideoPrivacy, - VideoTranscodingFPS, - JobType, VideoRateType, VideoResolution, - VideoState + VideoState, + VideoTranscodingFPS } from '../../shared/models' -// Do not use barrels, remain constants as independent as possible -import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils' +import { ActivityPubActorType } from '../../shared/models/activitypub' +import { FollowState } from '../../shared/models/actors' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' -import { invert } from 'lodash' -import { CronRepeatOptions, EveryRepeatOptions } from 'bull' import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' +// Do not use barrels, remain constants as independent as possible +import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- @@ -172,7 +172,7 @@ const JOB_TTL: { [id in JobType]: number } = { } const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = { 'videos-views': { - cron: '1 * * * *' // At 1 minute past the hour + cron: randomInt(1, 20) + ' * * * *' // Between 1-20 minutes past the hour } }