]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/plugins/plugin-manager.ts
Automatically rebuild native modules on ABI change
[github/Chocobozzz/PeerTube.git] / server / lib / plugins / plugin-manager.ts
index a706df1e0a0ed90a8423e21363f1c41f55a7b92e..a46b97fa46cfb069a2dec56379bf41a23f59ab11 100644 (file)
@@ -3,6 +3,7 @@ import { createReadStream, createWriteStream } from 'fs'
 import { ensureDir, outputFile, readJSON } from 'fs-extra'
 import { basename, join } from 'path'
 import { decachePlugin } from '@server/helpers/decache'
+import { ApplicationModel } from '@server/models/application/application'
 import { MOAuthTokenUser, MUser } from '@server/types/models'
 import { getCompleteLocale } from '@shared/core-utils'
 import {
@@ -23,7 +24,7 @@ import { PluginModel } from '../../models/server/plugin'
 import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPassOptions, RegisterServerOptions } from '../../types/plugins'
 import { ClientHtml } from '../client-html'
 import { RegisterHelpers } from './register-helpers'
-import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
+import { installNpmPlugin, installNpmPluginFromDisk, rebuildNativePlugins, removeNpmPlugin } from './yarn'
 
 export interface RegisteredPlugin {
   npmName: string
@@ -384,6 +385,12 @@ export class PluginManager implements ServerHook {
     logger.info('Plugin %s uninstalled.', npmName)
   }
 
+  async rebuildNativePluginsIfNeeded () {
+    if (!await ApplicationModel.nodeABIChanged()) return
+
+    return rebuildNativePlugins()
+  }
+
   // ###################### Private register ######################
 
   private async registerPluginOrTheme (plugin: PluginModel) {