From 2baea0c77cc765f7cbca9c9a2f4272268892a35c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Jun 2018 18:06:56 +0200 Subject: Add ability for uploaders to schedule video update --- server/initializers/constants.ts | 15 ++++++++++++--- server/initializers/database.ts | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 65f89ff7f..164378505 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -8,6 +8,8 @@ import { VideoPrivacy } from '../../shared/models/videos' import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' +import { RemoveOldJobsScheduler } from '../lib/schedulers/remove-old-jobs-scheduler' +import { UpdateVideosScheduler } from '../lib/schedulers/update-videos-scheduler' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -94,7 +96,11 @@ const JOB_REQUEST_TTL = 60000 * 10 // 10 minutes const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days // 1 hour -let SCHEDULER_INTERVAL = 60000 * 60 +let SCHEDULER_INTERVALS_MS = { + badActorFollow: 60000 * 60, // 1 hour + removeOldJobs: 60000 * 60, // 1 jour + updateVideos: 60000 * 1, // 1 minute +} // --------------------------------------------------------------------------- @@ -460,7 +466,10 @@ if (isTestInstance() === true) { CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB - SCHEDULER_INTERVAL = 10000 + SCHEDULER_INTERVALS_MS.badActorFollow = 10000 + SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 + SCHEDULER_INTERVALS_MS.updateVideos = 5000 + VIDEO_VIEW_LIFETIME = 1000 // 1 second JOB_ATTEMPTS['email'] = 1 @@ -513,7 +522,7 @@ export { JOB_REQUEST_TTL, USER_PASSWORD_RESET_LIFETIME, IMAGE_MIMETYPE_EXT, - SCHEDULER_INTERVAL, + SCHEDULER_INTERVALS_MS, STATIC_DOWNLOAD_PATHS, RATES_LIMIT, VIDEO_EXT_MIMETYPE, diff --git a/server/initializers/database.ts b/server/initializers/database.ts index b537ee59a..4d90c90fc 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -22,6 +22,7 @@ import { VideoFileModel } from '../models/video/video-file' import { VideoShareModel } from '../models/video/video-share' import { VideoTagModel } from '../models/video/video-tag' import { CONFIG } from './constants' +import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string @@ -73,7 +74,8 @@ async function initDatabaseModels (silent: boolean) { VideoBlacklistModel, VideoTagModel, VideoModel, - VideoCommentModel + VideoCommentModel, + ScheduleVideoUpdateModel ]) if (!silent) logger.info('Database %s is ready.', dbname) -- cgit v1.2.3