diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-03 15:08:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-03 15:08:36 +0200 |
commit | c795e19663a93c24908a7318975f820bac63164f (patch) | |
tree | 149a303be38eedf5aa5a0ec02938f67c75a267fe /server/lib | |
parent | fd59208e8ccd796f9ad7e35db82d0c33acfcb92c (diff) | |
download | PeerTube-c795e19663a93c24908a7318975f820bac63164f.tar.gz PeerTube-c795e19663a93c24908a7318975f820bac63164f.tar.zst PeerTube-c795e19663a93c24908a7318975f820bac63164f.zip |
Automatically rebuild native modules on ABI change
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 9 | ||||
-rw-r--r-- | server/lib/plugins/yarn.ts | 5 | ||||
-rw-r--r-- | server/lib/server-config-manager.ts | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index a706df1e0..a46b97fa4 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -3,6 +3,7 @@ import { createReadStream, createWriteStream } from 'fs' | |||
3 | import { ensureDir, outputFile, readJSON } from 'fs-extra' | 3 | import { ensureDir, outputFile, readJSON } from 'fs-extra' |
4 | import { basename, join } from 'path' | 4 | import { basename, join } from 'path' |
5 | import { decachePlugin } from '@server/helpers/decache' | 5 | import { decachePlugin } from '@server/helpers/decache' |
6 | import { ApplicationModel } from '@server/models/application/application' | ||
6 | import { MOAuthTokenUser, MUser } from '@server/types/models' | 7 | import { MOAuthTokenUser, MUser } from '@server/types/models' |
7 | import { getCompleteLocale } from '@shared/core-utils' | 8 | import { getCompleteLocale } from '@shared/core-utils' |
8 | import { | 9 | import { |
@@ -23,7 +24,7 @@ import { PluginModel } from '../../models/server/plugin' | |||
23 | import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPassOptions, RegisterServerOptions } from '../../types/plugins' | 24 | import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPassOptions, RegisterServerOptions } from '../../types/plugins' |
24 | import { ClientHtml } from '../client-html' | 25 | import { ClientHtml } from '../client-html' |
25 | import { RegisterHelpers } from './register-helpers' | 26 | import { RegisterHelpers } from './register-helpers' |
26 | import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' | 27 | import { installNpmPlugin, installNpmPluginFromDisk, rebuildNativePlugins, removeNpmPlugin } from './yarn' |
27 | 28 | ||
28 | export interface RegisteredPlugin { | 29 | export interface RegisteredPlugin { |
29 | npmName: string | 30 | npmName: string |
@@ -384,6 +385,12 @@ export class PluginManager implements ServerHook { | |||
384 | logger.info('Plugin %s uninstalled.', npmName) | 385 | logger.info('Plugin %s uninstalled.', npmName) |
385 | } | 386 | } |
386 | 387 | ||
388 | async rebuildNativePluginsIfNeeded () { | ||
389 | if (!await ApplicationModel.nodeABIChanged()) return | ||
390 | |||
391 | return rebuildNativePlugins() | ||
392 | } | ||
393 | |||
387 | // ###################### Private register ###################### | 394 | // ###################### Private register ###################### |
388 | 395 | ||
389 | private async registerPluginOrTheme (plugin: PluginModel) { | 396 | private async registerPluginOrTheme (plugin: PluginModel) { |
diff --git a/server/lib/plugins/yarn.ts b/server/lib/plugins/yarn.ts index 3f45681d3..d105b95e0 100644 --- a/server/lib/plugins/yarn.ts +++ b/server/lib/plugins/yarn.ts | |||
@@ -31,11 +31,16 @@ async function removeNpmPlugin (name: string) { | |||
31 | await execYarn('remove ' + name) | 31 | await execYarn('remove ' + name) |
32 | } | 32 | } |
33 | 33 | ||
34 | async function rebuildNativePlugins () { | ||
35 | await execYarn('install --pure-lockfile') | ||
36 | } | ||
37 | |||
34 | // ############################################################################ | 38 | // ############################################################################ |
35 | 39 | ||
36 | export { | 40 | export { |
37 | installNpmPlugin, | 41 | installNpmPlugin, |
38 | installNpmPluginFromDisk, | 42 | installNpmPluginFromDisk, |
43 | rebuildNativePlugins, | ||
39 | removeNpmPlugin | 44 | removeNpmPlugin |
40 | } | 45 | } |
41 | 46 | ||
diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts index d16a88f65..a3312fa20 100644 --- a/server/lib/server-config-manager.ts +++ b/server/lib/server-config-manager.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { getServerCommit } from '@server/helpers/utils' | 1 | import { getServerCommit } from '@server/helpers/version' |
2 | import { CONFIG, isEmailEnabled } from '@server/initializers/config' | 2 | import { CONFIG, isEmailEnabled } from '@server/initializers/config' |
3 | import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants' | 3 | import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants' |
4 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/lib/signup' | 4 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/lib/signup' |