Prosody AppImage: extract in a dedicated folder
This commit is contained in:
parent
27e8fbf05f
commit
8f5b2ae565
@ -33,6 +33,10 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
||||
let execCtl
|
||||
let execCtlArgs: string[]
|
||||
let appImageToExtract
|
||||
|
||||
// this one is always needed (must create the directory on startup)
|
||||
const appImageExtractPath = path.resolve(dir, '..', 'prosodyAppImage')
|
||||
|
||||
if (settings['use-system-prosody']) {
|
||||
exec = 'prosody'
|
||||
execArgs = []
|
||||
@ -40,11 +44,12 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
||||
execCtlArgs = []
|
||||
} else {
|
||||
appImageToExtract = path.resolve(__dirname, '../../prosody/livechat-prosody-x86_64.AppImage')
|
||||
exec = path.resolve(dir, 'squashfs-root/AppRun') // the AppImage will be extracted in the working dir
|
||||
exec = path.resolve(appImageExtractPath, 'squashfs-root/AppRun')
|
||||
execArgs = ['prosody']
|
||||
execCtl = exec
|
||||
execCtlArgs = ['prosodyctl']
|
||||
}
|
||||
|
||||
return {
|
||||
dir: dir,
|
||||
pid: path.resolve(dir, 'prosody.pid'),
|
||||
@ -58,7 +63,8 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
||||
execArgs,
|
||||
execCtl,
|
||||
execCtlArgs,
|
||||
appImageToExtract
|
||||
appImageToExtract,
|
||||
appImageExtractPath
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ interface ProsodyFilePaths {
|
||||
execCtl: string
|
||||
execCtlArgs: string[]
|
||||
appImageToExtract?: string
|
||||
appImageExtractPath: string
|
||||
}
|
||||
|
||||
export {
|
||||
|
@ -8,10 +8,11 @@ import * as child_process from 'child_process'
|
||||
async function _ensureWorkingDir (
|
||||
options: RegisterServerOptions,
|
||||
workingDir: string,
|
||||
dataDir: string
|
||||
dataDir: string,
|
||||
appImageExtractPath: string
|
||||
): Promise<string> {
|
||||
const logger = options.peertubeHelpers.logger
|
||||
logger.debug('Calling ensureworkingDir')
|
||||
logger.debug('Calling _ensureworkingDir')
|
||||
|
||||
if (!fs.existsSync(workingDir)) {
|
||||
logger.info(`The working dir ${workingDir} does not exists, trying to create it`)
|
||||
@ -25,7 +26,13 @@ async function _ensureWorkingDir (
|
||||
if (!fs.existsSync(dataDir)) {
|
||||
logger.info(`The data dir ${dataDir} does not exists, trying to create it`)
|
||||
await fs.promises.mkdir(dataDir)
|
||||
logger.debug(`Working dir ${dataDir} was created`)
|
||||
logger.debug(`data dir ${dataDir} was created`)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(appImageExtractPath)) {
|
||||
logger.info(`The appImageExtractPath dir ${appImageExtractPath} does not exists, trying to create it`)
|
||||
await fs.promises.mkdir(appImageExtractPath)
|
||||
logger.debug(`appImageExtractPath dir ${appImageExtractPath} was created`)
|
||||
}
|
||||
|
||||
return workingDir
|
||||
@ -42,7 +49,7 @@ async function prepareProsody (options: RegisterServerOptions): Promise<void> {
|
||||
const filePaths = await getProsodyFilePaths(options)
|
||||
|
||||
logger.debug('Ensuring that the working dir exists')
|
||||
await _ensureWorkingDir(options, filePaths.dir, filePaths.data)
|
||||
await _ensureWorkingDir(options, filePaths.dir, filePaths.data, filePaths.appImageExtractPath)
|
||||
|
||||
const appImageToExtract = filePaths.appImageToExtract
|
||||
if (!appImageToExtract) {
|
||||
@ -51,7 +58,7 @@ async function prepareProsody (options: RegisterServerOptions): Promise<void> {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const spawned = child_process.spawn(appImageToExtract, ['--appimage-extract'], {
|
||||
cwd: filePaths.dir,
|
||||
cwd: filePaths.appImageExtractPath,
|
||||
env: {
|
||||
...process.env
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user