diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-09 09:37:46 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-09 09:37:46 +0200 |
commit | bae930372678692f94601d503eaf7deabaa82a3f (patch) | |
tree | 58dddd58c1a4fe994a41f858451d972e8cee0897 /server | |
parent | 09d535ef9817a63096dc724cc4d9f0671ee6e5a3 (diff) | |
download | PeerTube-bae930372678692f94601d503eaf7deabaa82a3f.tar.gz PeerTube-bae930372678692f94601d503eaf7deabaa82a3f.tar.zst PeerTube-bae930372678692f94601d503eaf7deabaa82a3f.zip |
Also decache config
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/config.ts | 17 | ||||
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 3 |
2 files changed, 11 insertions, 9 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 93dd5ac04..4e15acd0d 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import * as bytes from 'bytes' | ||
1 | import { IConfig } from 'config' | 2 | import { IConfig } from 'config' |
3 | import decache from 'decache' | ||
2 | import { dirname, join } from 'path' | 4 | import { dirname, join } from 'path' |
5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | ||
6 | import { BroadcastMessageLevel } from '@shared/models/server' | ||
3 | import { VideosRedundancyStrategy } from '../../shared/models' | 7 | import { VideosRedundancyStrategy } from '../../shared/models' |
8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | ||
4 | // Do not use barrels, remain constants as independent as possible | 9 | // Do not use barrels, remain constants as independent as possible |
5 | import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' | 10 | import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' |
6 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | ||
7 | import * as bytes from 'bytes' | ||
8 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | ||
9 | import { BroadcastMessageLevel } from '@shared/models/server' | ||
10 | 11 | ||
11 | // Use a variable to reload the configuration if we need | 12 | // Use a variable to reload the configuration if we need |
12 | let config: IConfig = require('config') | 13 | let config: IConfig = require('config') |
@@ -410,7 +411,7 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] { | |||
410 | 411 | ||
411 | export function reloadConfig () { | 412 | export function reloadConfig () { |
412 | 413 | ||
413 | function directory () { | 414 | function getConfigDirectory () { |
414 | if (process.env.NODE_CONFIG_DIR) { | 415 | if (process.env.NODE_CONFIG_DIR) { |
415 | return process.env.NODE_CONFIG_DIR | 416 | return process.env.NODE_CONFIG_DIR |
416 | } | 417 | } |
@@ -419,15 +420,17 @@ export function reloadConfig () { | |||
419 | } | 420 | } |
420 | 421 | ||
421 | function purge () { | 422 | function purge () { |
423 | const directory = getConfigDirectory() | ||
424 | |||
422 | for (const fileName in require.cache) { | 425 | for (const fileName in require.cache) { |
423 | if (fileName.includes(directory()) === false) { | 426 | if (fileName.includes(directory) === false) { |
424 | continue | 427 | continue |
425 | } | 428 | } |
426 | 429 | ||
427 | delete require.cache[fileName] | 430 | delete require.cache[fileName] |
428 | } | 431 | } |
429 | 432 | ||
430 | delete require.cache[require.resolve('config')] | 433 | decache('config') |
431 | } | 434 | } |
432 | 435 | ||
433 | purge() | 436 | purge() |
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 0086a0e2e..e3226a950 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import decache from 'decache' | ||
1 | import * as express from 'express' | 2 | import * as express from 'express' |
2 | import { createReadStream, createWriteStream } from 'fs' | 3 | import { createReadStream, createWriteStream } from 'fs' |
3 | import { outputFile, readJSON } from 'fs-extra' | 4 | import { outputFile, readJSON } from 'fs-extra' |
@@ -23,8 +24,6 @@ import { ClientHtml } from '../client-html' | |||
23 | import { RegisterHelpers } from './register-helpers' | 24 | import { RegisterHelpers } from './register-helpers' |
24 | import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' | 25 | import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' |
25 | 26 | ||
26 | const decache = require('decache') | ||
27 | |||
28 | export interface RegisteredPlugin { | 27 | export interface RegisteredPlugin { |
29 | npmName: string | 28 | npmName: string |
30 | name: string | 29 | name: string |