aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-after-init.ts10
-rw-r--r--server/initializers/checker-before-init.ts5
-rw-r--r--server/initializers/config.ts2
-rw-r--r--server/initializers/installer.ts8
-rw-r--r--server/initializers/migrator.ts10
5 files changed, 19 insertions, 16 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 09f587274..c0a6c41ab 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -1,4 +1,4 @@
1import * as config from 'config' 1import { util, has, get } from 'config'
2import { uniq } from 'lodash' 2import { uniq } from 'lodash'
3import { URL } from 'url' 3import { URL } from 'url'
4import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' 4import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils'
@@ -18,8 +18,8 @@ async function checkActivityPubUrls () {
18 18
19 const parsed = new URL(actor.url) 19 const parsed = new URL(actor.url)
20 if (WEBSERVER.HOST !== parsed.host) { 20 if (WEBSERVER.HOST !== parsed.host) {
21 const NODE_ENV = config.util.getEnv('NODE_ENV') 21 const NODE_ENV = util.getEnv('NODE_ENV')
22 const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR') 22 const NODE_CONFIG_DIR = util.getEnv('NODE_CONFIG_DIR')
23 23
24 logger.warn( 24 logger.warn(
25 'It seems PeerTube was started (and created some data) with another domain name. ' + 25 'It seems PeerTube was started (and created some data) with another domain name. ' +
@@ -36,7 +36,7 @@ async function checkActivityPubUrls () {
36function checkConfig () { 36function checkConfig () {
37 37
38 // Moved configuration keys 38 // Moved configuration keys
39 if (config.has('services.csp-logger')) { 39 if (has('services.csp-logger')) {
40 logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.') 40 logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
41 } 41 }
42 42
@@ -97,7 +97,7 @@ function checkConfig () {
97 97
98 // Check storage directory locations 98 // Check storage directory locations
99 if (isProdInstance()) { 99 if (isProdInstance()) {
100 const configStorage = config.get('storage') 100 const configStorage = get('storage')
101 for (const key of Object.keys(configStorage)) { 101 for (const key of Object.keys(configStorage)) {
102 if (configStorage[key].startsWith('storage/')) { 102 if (configStorage[key].startsWith('storage/')) {
103 logger.warn( 103 logger.warn(
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 93c019121..16dc137c0 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -1,7 +1,10 @@
1import * as config from 'config' 1import { IConfig } from 'config'
2import { parseSemVersion, promisify0 } from '../helpers/core-utils' 2import { parseSemVersion, promisify0 } from '../helpers/core-utils'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4 4
5// Special behaviour for config because we can reload it
6const config: IConfig = require('config')
7
5// ONLY USE CORE MODULES IN THIS FILE! 8// ONLY USE CORE MODULES IN THIS FILE!
6 9
7// Check the config files 10// Check the config files
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 0e684eef8..be9fc61f0 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -1,4 +1,4 @@
1import * as bytes from 'bytes' 1import bytes from 'bytes'
2import { IConfig } from 'config' 2import { IConfig } from 'config'
3import decache from 'decache' 3import decache from 'decache'
4import { dirname, join } from 'path' 4import { dirname, join } from 'path'
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 676f88653..75daeb5d8 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -1,15 +1,15 @@
1import * as passwordGenerator from 'password-generator' 1import { ensureDir, remove } from 'fs-extra'
2import passwordGenerator from 'password-generator'
2import { UserRole } from '../../shared' 3import { UserRole } from '../../shared'
3import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
4import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' 5import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
5import { UserModel } from '../models/user/user'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { UserModel } from '../models/user/user'
8import { applicationExist, clientsExist, usersExist } from './checker-after-init' 9import { applicationExist, clientsExist, usersExist } from './checker-after-init'
10import { CONFIG } from './config'
9import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' 11import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants'
10import { sequelizeTypescript } from './database' 12import { sequelizeTypescript } from './database'
11import { ensureDir, remove } from 'fs-extra'
12import { CONFIG } from './config'
13 13
14async function installApplication () { 14async function installApplication () {
15 try { 15 try {
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts
index 77203ae24..7d7c9f8cb 100644
--- a/server/initializers/migrator.ts
+++ b/server/initializers/migrator.ts
@@ -1,9 +1,9 @@
1import * as path from 'path' 1import { readdir } from 'fs-extra'
2import { join } from 'path'
3import { QueryTypes } from 'sequelize'
2import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
3import { LAST_MIGRATION_VERSION } from './constants' 5import { LAST_MIGRATION_VERSION } from './constants'
4import { sequelizeTypescript } from './database' 6import { sequelizeTypescript } from './database'
5import { readdir } from 'fs-extra'
6import { QueryTypes } from 'sequelize'
7 7
8async function migrate () { 8async function migrate () {
9 const tables = await sequelizeTypescript.getQueryInterface().showAllTables() 9 const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
@@ -58,7 +58,7 @@ export {
58// --------------------------------------------------------------------------- 58// ---------------------------------------------------------------------------
59 59
60async function getMigrationScripts () { 60async function getMigrationScripts () {
61 const files = await readdir(path.join(__dirname, 'migrations')) 61 const files = await readdir(join(__dirname, 'migrations'))
62 const filesToMigrate: { 62 const filesToMigrate: {
63 version: string 63 version: string
64 script: string 64 script: string
@@ -88,7 +88,7 @@ async function executeMigration (actualVersion: number, entity: { version: strin
88 const migrationScriptName = entity.script 88 const migrationScriptName = entity.script
89 logger.info('Executing %s migration script.', migrationScriptName) 89 logger.info('Executing %s migration script.', migrationScriptName)
90 90
91 const migrationScript = require(path.join(__dirname, 'migrations', migrationScriptName)) 91 const migrationScript = require(join(__dirname, 'migrations', migrationScriptName))
92 92
93 return sequelizeTypescript.transaction(async t => { 93 return sequelizeTypescript.transaction(async t => {
94 const options = { 94 const options = {