Prosody AppImage: extract in a dedicated folder

This commit is contained in:
John Livingston 2022-11-15 16:30:24 +01:00
parent 27e8fbf05f
commit 8f5b2ae565
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 21 additions and 7 deletions

View File

@ -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
}
}

View File

@ -12,6 +12,7 @@ interface ProsodyFilePaths {
execCtl: string
execCtlArgs: string[]
appImageToExtract?: string
appImageExtractPath: string
}
export {

View File

@ -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
}