From 9452d4fd3321148fb80b64a67bd9983fee6c208e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Jul 2022 15:44:14 +0200 Subject: /!\ Use a dedicated config file for development It means you have to replace NODE_ENV=test to NODE_ENV=dev if you use it npm run dev:* commands are already updated --- server/lib/client-html.ts | 4 ++-- server/lib/emailer.ts | 6 +++--- server/lib/job-queue/handlers/video-views-stats.ts | 4 ++-- server/lib/schedulers/actor-follow-scheduler.ts | 4 ++-- server/lib/schedulers/remove-old-jobs-scheduler.ts | 6 +++--- server/lib/views/shared/video-viewer-counters.ts | 4 ++-- server/lib/views/shared/video-viewer-stats.ts | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'server/lib') diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 1e8d03023..899d80c15 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -2,6 +2,7 @@ import express from 'express' import { readFile } from 'fs-extra' import { join } from 'path' import validator from 'validator' +import { isTestOrDevInstance } from '@server/helpers/core-utils' import { toCompleteUUID } from '@server/helpers/custom-validators/misc' import { mdToOneLinePlainText } from '@server/helpers/markdown' import { ActorImageModel } from '@server/models/actor/actor-image' @@ -30,7 +31,6 @@ import { MAccountActor, MChannelActor } from '../types/models' import { getActivityStreamDuration } from './activitypub/activity' import { getBiggestActorImage } from './actor-image' import { ServerConfigManager } from './server-config-manager' -import { isTestInstance } from '@server/helpers/core-utils' type Tags = { ogType: string @@ -234,7 +234,7 @@ class ClientHtml { const path = ClientHtml.getEmbedPath() // Disable HTML cache in dev mode because webpack can regenerate JS files - if (!isTestInstance() && ClientHtml.htmlCache[path]) { + if (!isTestOrDevInstance() && ClientHtml.htmlCache[path]) { return ClientHtml.htmlCache[path] } diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index edc99057c..42d7650dd 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts @@ -2,10 +2,10 @@ import { readFileSync } from 'fs-extra' import { isArray, merge } from 'lodash' import { createTransport, Transporter } from 'nodemailer' import { join } from 'path' +import { root } from '@shared/core-utils' import { EmailPayload } from '@shared/models' import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' -import { isTestInstance } from '../helpers/core-utils' -import { root } from '@shared/core-utils' +import { isTestOrDevInstance } from '../helpers/core-utils' import { bunyanLogger, logger } from '../helpers/logger' import { CONFIG, isEmailEnabled } from '../initializers/config' import { WEBSERVER } from '../initializers/constants' @@ -29,7 +29,7 @@ class Emailer { this.initialized = true if (!isEmailEnabled()) { - if (!isTestInstance()) { + if (!isTestOrDevInstance()) { logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!') } diff --git a/server/lib/job-queue/handlers/video-views-stats.ts b/server/lib/job-queue/handlers/video-views-stats.ts index 689a5a3b4..c9aa218e5 100644 --- a/server/lib/job-queue/handlers/video-views-stats.ts +++ b/server/lib/job-queue/handlers/video-views-stats.ts @@ -1,5 +1,5 @@ import { VideoViewModel } from '@server/models/view/video-view' -import { isTestInstance } from '../../../helpers/core-utils' +import { isTestOrDevInstance } from '../../../helpers/core-utils' import { logger } from '../../../helpers/logger' import { VideoModel } from '../../../models/video/video' import { Redis } from '../../redis' @@ -8,7 +8,7 @@ async function processVideosViewsStats () { const lastHour = new Date() // In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour - if (!isTestInstance()) lastHour.setHours(lastHour.getHours() - 1) + if (!isTestOrDevInstance()) lastHour.setHours(lastHour.getHours() - 1) const hour = lastHour.getHours() const startDate = lastHour.setMinutes(0, 0, 0) diff --git a/server/lib/schedulers/actor-follow-scheduler.ts b/server/lib/schedulers/actor-follow-scheduler.ts index 560f97f3e..e1c56c135 100644 --- a/server/lib/schedulers/actor-follow-scheduler.ts +++ b/server/lib/schedulers/actor-follow-scheduler.ts @@ -1,4 +1,4 @@ -import { isTestInstance } from '../../helpers/core-utils' +import { isTestOrDevInstance } from '../../helpers/core-utils' import { logger } from '../../helpers/logger' import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' import { ActorFollowModel } from '../../models/actor/actor-follow' @@ -39,7 +39,7 @@ export class ActorFollowScheduler extends AbstractScheduler { } private async removeBadActorFollows () { - if (!isTestInstance()) logger.info('Removing bad actor follows (scheduler).') + if (!isTestOrDevInstance()) logger.info('Removing bad actor follows (scheduler).') try { await ActorFollowModel.removeBadActorFollows() diff --git a/server/lib/schedulers/remove-old-jobs-scheduler.ts b/server/lib/schedulers/remove-old-jobs-scheduler.ts index dffef3542..879846999 100644 --- a/server/lib/schedulers/remove-old-jobs-scheduler.ts +++ b/server/lib/schedulers/remove-old-jobs-scheduler.ts @@ -1,8 +1,8 @@ -import { isTestInstance } from '../../helpers/core-utils' +import { isTestOrDevInstance } from '../../helpers/core-utils' import { logger } from '../../helpers/logger' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' import { JobQueue } from '../job-queue' import { AbstractScheduler } from './abstract-scheduler' -import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' export class RemoveOldJobsScheduler extends AbstractScheduler { @@ -15,7 +15,7 @@ export class RemoveOldJobsScheduler extends AbstractScheduler { } protected internalExecute () { - if (!isTestInstance()) logger.info('Removing old jobs in scheduler.') + if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.') return JobQueue.Instance.removeOldJobs() } diff --git a/server/lib/views/shared/video-viewer-counters.ts b/server/lib/views/shared/video-viewer-counters.ts index cf3fa5882..f851ce050 100644 --- a/server/lib/views/shared/video-viewer-counters.ts +++ b/server/lib/views/shared/video-viewer-counters.ts @@ -1,4 +1,4 @@ -import { isTestInstance } from '@server/helpers/core-utils' +import { isTestOrDevInstance } from '@server/helpers/core-utils' import { logger, loggerTagsFactory } from '@server/helpers/logger' import { VIEW_LIFETIME } from '@server/initializers/constants' import { sendView } from '@server/lib/activitypub/send/send-view' @@ -117,7 +117,7 @@ export class VideoViewerCounters { if (this.processingViewerCounters) return this.processingViewerCounters = true - if (!isTestInstance()) logger.info('Cleaning video viewers.', lTags()) + if (!isTestOrDevInstance()) logger.info('Cleaning video viewers.', lTags()) try { for (const videoId of this.viewersPerVideo.keys()) { diff --git a/server/lib/views/shared/video-viewer-stats.ts b/server/lib/views/shared/video-viewer-stats.ts index a56c20559..542bd51cf 100644 --- a/server/lib/views/shared/video-viewer-stats.ts +++ b/server/lib/views/shared/video-viewer-stats.ts @@ -1,5 +1,5 @@ import { Transaction } from 'sequelize/types' -import { isTestInstance } from '@server/helpers/core-utils' +import { isTestOrDevInstance } from '@server/helpers/core-utils' import { GeoIP } from '@server/helpers/geo-ip' import { logger, loggerTagsFactory } from '@server/helpers/logger' import { MAX_LOCAL_VIEWER_WATCH_SECTIONS, VIEW_LIFETIME } from '@server/initializers/constants' @@ -118,7 +118,7 @@ export class VideoViewerStats { if (this.processingViewersStats) return this.processingViewersStats = true - if (!isTestInstance()) logger.info('Processing viewer statistics.', lTags()) + if (!isTestOrDevInstance()) logger.info('Processing viewer statistics.', lTags()) const now = new Date().getTime() -- cgit v1.2.3