X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=server%2Finitializers%2Fconstants.ts;h=2d9a2e670a2c8311e1c1837bfafc5a47e0a4e1a9;hb=6b6168606bc86430f6b7821c9d5f1c80d0425ebf;hp=7f1b25654cc072879986530bb86847875361ce31;hpb=2d9fea161fd4fc73994fc77951bafdccdc2071fd;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 7f1b25654..2d9a2e670 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -3,11 +3,12 @@ import { dirname, join } from 'path' import { JobType, VideoRateType, VideoState } from '../../shared/models' import { ActivityPubActorType } from '../../shared/models/activitypub' import { FollowState } from '../../shared/models/actors' -import { VideoPrivacy, VideoAbuseState, VideoImportState } from '../../shared/models/videos' +import { VideoAbuseState, VideoImportState, VideoPrivacy } from '../../shared/models/videos' // Do not use barrels, remain constants as independent as possible import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' +import { CronRepeatOptions, EveryRepeatOptions } from 'bull' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -90,7 +91,8 @@ const JOB_ATTEMPTS: { [ id in JobType ]: number } = { 'video-file-import': 1, 'video-file': 1, 'video-import': 1, - 'email': 5 + 'email': 5, + 'videos-views': 1 } const JOB_CONCURRENCY: { [ id in JobType ]: number } = { 'activitypub-http-broadcast': 1, @@ -100,7 +102,8 @@ const JOB_CONCURRENCY: { [ id in JobType ]: number } = { 'video-file-import': 1, 'video-file': 1, 'video-import': 1, - 'email': 5 + 'email': 5, + 'videos-views': 1 } const JOB_TTL: { [ id in JobType ]: number } = { 'activitypub-http-broadcast': 60000 * 10, // 10 minutes @@ -110,8 +113,15 @@ const JOB_TTL: { [ id in JobType ]: number } = { 'video-file-import': 1000 * 3600, // 1 hour 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long 'video-import': 1000 * 3600 * 5, // 5 hours - 'email': 60000 * 10 // 10 minutes + 'email': 60000 * 10, // 10 minutes + 'videos-views': undefined // Unlimited } +const REPEAT_JOBS: { [ id: string ]: EveryRepeatOptions | CronRepeatOptions } = { + 'videos-views': { + cron: '1 * * * *' // At 1 minutes past the hour + } +} + const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds @@ -591,6 +601,7 @@ if (isTestInstance() === true) { SCHEDULER_INTERVALS_MS.badActorFollow = 10000 SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 SCHEDULER_INTERVALS_MS.updateVideos = 5000 + REPEAT_JOBS['videos-views'] = { every: 5000 } VIDEO_VIEW_LIFETIME = 1000 // 1 second @@ -652,6 +663,7 @@ export { USER_PASSWORD_RESET_LIFETIME, IMAGE_MIMETYPE_EXT, SCHEDULER_INTERVALS_MS, + REPEAT_JOBS, STATIC_DOWNLOAD_PATHS, RATES_LIMIT, VIDEO_EXT_MIMETYPE,