diff options
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/checker-after-init.ts | 27 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 6 | ||||
-rw-r--r-- | server/initializers/config.ts | 6 | ||||
-rw-r--r-- | server/initializers/constants.ts | 6 | ||||
-rw-r--r-- | server/initializers/database.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0610-views-index copy.ts (renamed from server/initializers/migrations/0610-views-index.ts) | 0 | ||||
-rw-r--r-- | server/initializers/migrations/0615-latest-versions-notification-settings.ts | 44 | ||||
-rw-r--r-- | server/initializers/migrations/0620-latest-versions-application.ts | 27 | ||||
-rw-r--r-- | server/initializers/migrations/0625-latest-versions-notification.ts | 26 |
9 files changed, 130 insertions, 14 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 2b00e2047..a93c8b7fd 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -1,16 +1,17 @@ | |||
1 | import * as config from 'config' | 1 | import * as config from 'config' |
2 | import { isProdInstance, isTestInstance } from '../helpers/core-utils' | 2 | import { uniq } from 'lodash' |
3 | import { UserModel } from '../models/account/user' | ||
4 | import { getServerActor, ApplicationModel } from '../models/application/application' | ||
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | ||
6 | import { URL } from 'url' | 3 | import { URL } from 'url' |
7 | import { CONFIG, isEmailEnabled } from './config' | 4 | import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' |
8 | import { logger } from '../helpers/logger' | 5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' |
9 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' | 6 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' |
7 | import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils' | ||
10 | import { isArray } from '../helpers/custom-validators/misc' | 8 | import { isArray } from '../helpers/custom-validators/misc' |
11 | import { uniq } from 'lodash' | 9 | import { logger } from '../helpers/logger' |
10 | import { UserModel } from '../models/account/user' | ||
11 | import { ApplicationModel, getServerActor } from '../models/application/application' | ||
12 | import { OAuthClientModel } from '../models/oauth/oauth-client' | ||
13 | import { CONFIG, isEmailEnabled } from './config' | ||
12 | import { WEBSERVER } from './constants' | 14 | import { WEBSERVER } from './constants' |
13 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | ||
14 | 15 | ||
15 | async function checkActivityPubUrls () { | 16 | async function checkActivityPubUrls () { |
16 | const actor = await getServerActor() | 17 | const actor = await getServerActor() |
@@ -176,11 +177,21 @@ async function applicationExist () { | |||
176 | return totalApplication !== 0 | 177 | return totalApplication !== 0 |
177 | } | 178 | } |
178 | 179 | ||
180 | async function checkFFmpegVersion () { | ||
181 | const version = await getFFmpegVersion() | ||
182 | const { major, minor } = parseSemVersion(version) | ||
183 | |||
184 | if (major < 4 || (major === 4 && minor < 1)) { | ||
185 | logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade.', version) | ||
186 | } | ||
187 | } | ||
188 | |||
179 | // --------------------------------------------------------------------------- | 189 | // --------------------------------------------------------------------------- |
180 | 190 | ||
181 | export { | 191 | export { |
182 | checkConfig, | 192 | checkConfig, |
183 | clientsExist, | 193 | clientsExist, |
194 | checkFFmpegVersion, | ||
184 | usersExist, | 195 | usersExist, |
185 | applicationExist, | 196 | applicationExist, |
186 | checkActivityPubUrls | 197 | checkActivityPubUrls |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 565e0d1fa..e92cc4d2c 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as config from 'config' | 1 | import * as config from 'config' |
2 | import { promisify0 } from '../helpers/core-utils' | 2 | import { parseSemVersion, promisify0 } from '../helpers/core-utils' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | 4 | ||
5 | // ONLY USE CORE MODULES IN THIS FILE! | 5 | // ONLY USE CORE MODULES IN THIS FILE! |
@@ -37,6 +37,7 @@ function checkMissedConfig () { | |||
37 | 'theme.default', | 37 | 'theme.default', |
38 | 'remote_redundancy.videos.accept_from', | 38 | 'remote_redundancy.videos.accept_from', |
39 | 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions', | 39 | 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions', |
40 | 'peertube.check_latest_version.enabled', 'peertube.check_latest_version.url', | ||
40 | 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', | 41 | 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', |
41 | 'search.search_index.disable_local_search', 'search.search_index.is_default_search', | 42 | 'search.search_index.disable_local_search', 'search.search_index.is_default_search', |
42 | 'live.enabled', 'live.allow_replay', 'live.max_duration', 'live.max_user_lives', 'live.max_instance_lives', | 43 | 'live.enabled', 'live.allow_replay', 'live.max_duration', 'live.max_user_lives', 'live.max_instance_lives', |
@@ -102,8 +103,7 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { | |||
102 | 103 | ||
103 | function checkNodeVersion () { | 104 | function checkNodeVersion () { |
104 | const v = process.version | 105 | const v = process.version |
105 | const majorString = v.split('.')[0].replace('v', '') | 106 | const { major } = parseSemVersion(v) |
106 | const major = parseInt(majorString, 10) | ||
107 | 107 | ||
108 | logger.debug('Checking NodeJS version %s.', v) | 108 | logger.debug('Checking NodeJS version %s.', v) |
109 | 109 | ||
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index c16b63c33..48e7f7397 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -163,6 +163,12 @@ const CONFIG = { | |||
163 | CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions') | 163 | CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions') |
164 | } | 164 | } |
165 | }, | 165 | }, |
166 | PEERTUBE: { | ||
167 | CHECK_LATEST_VERSION: { | ||
168 | ENABLED: config.get<boolean>('peertube.check_latest_version.enabled'), | ||
169 | URL: config.get<string>('peertube.check_latest_version.url') | ||
170 | } | ||
171 | }, | ||
166 | ADMIN: { | 172 | ADMIN: { |
167 | get EMAIL () { return config.get<string>('admin.email') } | 173 | get EMAIL () { return config.get<string>('admin.email') } |
168 | }, | 174 | }, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 1623e6f42..b37aeb622 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -24,12 +24,12 @@ import { CONFIG, registerConfigChangedHandler } from './config' | |||
24 | 24 | ||
25 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
26 | 26 | ||
27 | const LAST_MIGRATION_VERSION = 610 | 27 | const LAST_MIGRATION_VERSION = 625 |
28 | 28 | ||
29 | // --------------------------------------------------------------------------- | 29 | // --------------------------------------------------------------------------- |
30 | 30 | ||
31 | const API_VERSION = 'v1' | 31 | const API_VERSION = 'v1' |
32 | const PEERTUBE_VERSION = require(join(root(), 'package.json')).version | 32 | const PEERTUBE_VERSION: string = require(join(root(), 'package.json')).version |
33 | 33 | ||
34 | const PAGINATION = { | 34 | const PAGINATION = { |
35 | GLOBAL: { | 35 | GLOBAL: { |
@@ -207,6 +207,7 @@ const SCHEDULER_INTERVALS_MS = { | |||
207 | updateVideos: 60000, // 1 minute | 207 | updateVideos: 60000, // 1 minute |
208 | youtubeDLUpdate: 60000 * 60 * 24, // 1 day | 208 | youtubeDLUpdate: 60000 * 60 * 24, // 1 day |
209 | checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, | 209 | checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, |
210 | checkPeerTubeVersion: 60000 * 60 * 24, // 1 day | ||
210 | autoFollowIndexInstances: 60000 * 60 * 24, // 1 day | 211 | autoFollowIndexInstances: 60000 * 60 * 24, // 1 day |
211 | removeOldViews: 60000 * 60 * 24, // 1 day | 212 | removeOldViews: 60000 * 60 * 24, // 1 day |
212 | removeOldHistory: 60000 * 60 * 24, // 1 day | 213 | removeOldHistory: 60000 * 60 * 24, // 1 day |
@@ -763,6 +764,7 @@ if (isTestInstance() === true) { | |||
763 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 | 764 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
764 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 | 765 | SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 |
765 | SCHEDULER_INTERVALS_MS.updateInboxStats = 5000 | 766 | SCHEDULER_INTERVALS_MS.updateInboxStats = 5000 |
767 | SCHEDULER_INTERVALS_MS.checkPeerTubeVersion = 2000 | ||
766 | REPEAT_JOBS['videos-views'] = { every: 5000 } | 768 | REPEAT_JOBS['videos-views'] = { every: 5000 } |
767 | REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 } | 769 | REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 } |
768 | 770 | ||
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 1f2b6d521..8378fa982 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -76,7 +76,7 @@ const sequelizeTypescript = new SequelizeTypescript({ | |||
76 | newMessage += ' in ' + benchmark + 'ms' | 76 | newMessage += ' in ' + benchmark + 'ms' |
77 | } | 77 | } |
78 | 78 | ||
79 | logger.debug(newMessage, { sql: message }) | 79 | logger.debug(newMessage, { sql: message, tags: [ 'sql' ] }) |
80 | } | 80 | } |
81 | }) | 81 | }) |
82 | 82 | ||
diff --git a/server/initializers/migrations/0610-views-index.ts b/server/initializers/migrations/0610-views-index copy.ts index 02ee21172..02ee21172 100644 --- a/server/initializers/migrations/0610-views-index.ts +++ b/server/initializers/migrations/0610-views-index copy.ts | |||
diff --git a/server/initializers/migrations/0615-latest-versions-notification-settings.ts b/server/initializers/migrations/0615-latest-versions-notification-settings.ts new file mode 100644 index 000000000..86bf56009 --- /dev/null +++ b/server/initializers/migrations/0615-latest-versions-notification-settings.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | { | ||
10 | const notificationSettingColumns = [ 'newPeerTubeVersion', 'newPluginVersion' ] | ||
11 | |||
12 | for (const column of notificationSettingColumns) { | ||
13 | const data = { | ||
14 | type: Sequelize.INTEGER, | ||
15 | defaultValue: null, | ||
16 | allowNull: true | ||
17 | } | ||
18 | await utils.queryInterface.addColumn('userNotificationSetting', column, data) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const query = 'UPDATE "userNotificationSetting" SET "newPeerTubeVersion" = 3, "newPluginVersion" = 1' | ||
23 | await utils.sequelize.query(query) | ||
24 | } | ||
25 | |||
26 | for (const column of notificationSettingColumns) { | ||
27 | const data = { | ||
28 | type: Sequelize.INTEGER, | ||
29 | defaultValue: null, | ||
30 | allowNull: false | ||
31 | } | ||
32 | await utils.queryInterface.changeColumn('userNotificationSetting', column, data) | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | |||
37 | function down (options) { | ||
38 | throw new Error('Not implemented.') | ||
39 | } | ||
40 | |||
41 | export { | ||
42 | up, | ||
43 | down | ||
44 | } | ||
diff --git a/server/initializers/migrations/0620-latest-versions-application.ts b/server/initializers/migrations/0620-latest-versions-application.ts new file mode 100644 index 000000000..a689b18fc --- /dev/null +++ b/server/initializers/migrations/0620-latest-versions-application.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | |||
10 | { | ||
11 | const data = { | ||
12 | type: Sequelize.STRING, | ||
13 | defaultValue: null, | ||
14 | allowNull: true | ||
15 | } | ||
16 | await utils.queryInterface.addColumn('application', 'latestPeerTubeVersion', data) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0625-latest-versions-notification.ts b/server/initializers/migrations/0625-latest-versions-notification.ts new file mode 100644 index 000000000..77f395ce4 --- /dev/null +++ b/server/initializers/migrations/0625-latest-versions-notification.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | |||
10 | { | ||
11 | await utils.sequelize.query(` | ||
12 | ALTER TABLE "userNotification" | ||
13 | ADD COLUMN "applicationId" INTEGER REFERENCES "application" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
14 | ADD COLUMN "pluginId" INTEGER REFERENCES "plugin" ("id") ON DELETE SET NULL ON UPDATE CASCADE | ||
15 | `) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||