aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/config.ts')
-rw-r--r--server/initializers/config.ts17
1 files changed, 10 insertions, 7 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 @@
1import * as bytes from 'bytes'
1import { IConfig } from 'config' 2import { IConfig } from 'config'
3import decache from 'decache'
2import { dirname, join } from 'path' 4import { dirname, join } from 'path'
5import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
6import { BroadcastMessageLevel } from '@shared/models/server'
3import { VideosRedundancyStrategy } from '../../shared/models' 7import { VideosRedundancyStrategy } from '../../shared/models'
8import { 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
5import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' 10import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils'
6import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
7import * as bytes from 'bytes'
8import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
9import { 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
12let config: IConfig = require('config') 13let config: IConfig = require('config')
@@ -410,7 +411,7 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
410 411
411export function reloadConfig () { 412export 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()