Builtin prosody use a working dir provided by Peertube.
This commit is contained in:
parent
0305b849cf
commit
094193a3b1
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Not Released Yet
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Builtin prosody use a working dir provided by Peertube (needs Peertube >= 3.2.0)
|
||||||
|
|
||||||
## v2.2.0
|
## v2.2.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
6
server/@types/peertube.d.ts
vendored
6
server/@types/peertube.d.ts
vendored
@ -154,6 +154,12 @@ interface PeerTubeHelpers {
|
|||||||
user?: {
|
user?: {
|
||||||
getAuthUser: (res: express.Response) => Promise<MUserDefault | undefined>
|
getAuthUser: (res: express.Response) => Promise<MUserDefault | undefined>
|
||||||
}
|
}
|
||||||
|
// Added in Peertube 3.2.0
|
||||||
|
plugin?: {
|
||||||
|
getBaseStaticRoute: () => string
|
||||||
|
getBaseRouterRoute: () => string
|
||||||
|
getDataDirectoryPath: () => string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RegisterServerOptions {
|
interface RegisterServerOptions {
|
||||||
|
@ -8,8 +8,13 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
|
|||||||
result.label = 'Builtin Prosody and ConverseJS'
|
result.label = 'Builtin Prosody and ConverseJS'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dir = await getWorkingDir(options)
|
const workingDir = await getWorkingDir(options)
|
||||||
result.messages.push('The working dir is: ' + dir)
|
result.messages.push('The working dir is: ' + workingDir.dir)
|
||||||
|
if (workingDir.permanent) {
|
||||||
|
result.messages.push('The working dir is permanent')
|
||||||
|
} else {
|
||||||
|
result.messages.push('The working dir is a temporary directory')
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
result.messages.push('Error when requiring the working dir: ' + (error as string))
|
result.messages.push('Error when requiring the working dir: ' + (error as string))
|
||||||
return result
|
return result
|
||||||
|
@ -6,10 +6,7 @@ import { ProsodyConfigContent } from './config/content'
|
|||||||
import { getProsodyDomain } from './config/domain'
|
import { getProsodyDomain } from './config/domain'
|
||||||
import { getAPIKey } from '../apikey'
|
import { getAPIKey } from '../apikey'
|
||||||
|
|
||||||
async function getWorkingDir ({ peertubeHelpers, storageManager }: RegisterServerOptions): Promise<string> {
|
async function _getTemporaryWorkingDir ({ peertubeHelpers, storageManager }: RegisterServerOptions): Promise<string> {
|
||||||
const logger = peertubeHelpers.logger
|
|
||||||
logger.debug('Calling getWorkingDir')
|
|
||||||
|
|
||||||
const tmpBaseDir = '/tmp/'
|
const tmpBaseDir = '/tmp/'
|
||||||
let value: string = await storageManager.getData('tempDirId')
|
let value: string = await storageManager.getData('tempDirId')
|
||||||
|
|
||||||
@ -30,10 +27,34 @@ async function getWorkingDir ({ peertubeHelpers, storageManager }: RegisterServe
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dir = getPath(value)
|
const dir = getPath(value)
|
||||||
logger.debug('getWorkingDir will return ' + dir)
|
|
||||||
return dir
|
return dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getWorkingDir (options: RegisterServerOptions): Promise<{
|
||||||
|
dir: string
|
||||||
|
permanent: boolean
|
||||||
|
}> {
|
||||||
|
const peertubeHelpers = options.peertubeHelpers
|
||||||
|
const logger = peertubeHelpers.logger
|
||||||
|
logger.debug('Calling getWorkingDir')
|
||||||
|
|
||||||
|
if (peertubeHelpers.plugin?.getDataDirectoryPath) {
|
||||||
|
const dir = path.resolve(peertubeHelpers.plugin.getDataDirectoryPath(), 'prosody')
|
||||||
|
logger.debug('getWorkingDir will return the permanent dir ' + dir)
|
||||||
|
return {
|
||||||
|
dir: dir,
|
||||||
|
permanent: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dir = await _getTemporaryWorkingDir(options)
|
||||||
|
logger.debug('getWorkingDir will return the temporary dir ' + dir)
|
||||||
|
return {
|
||||||
|
dir: dir,
|
||||||
|
permanent: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the working dir if needed, and returns it.
|
* Creates the working dir if needed, and returns it.
|
||||||
* NB: for now, I try to create a directory in /tmp/.
|
* NB: for now, I try to create a directory in /tmp/.
|
||||||
@ -68,9 +89,11 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
|||||||
const logger = options.peertubeHelpers.logger
|
const logger = options.peertubeHelpers.logger
|
||||||
logger.debug('Calling getProsodyFilePaths')
|
logger.debug('Calling getProsodyFilePaths')
|
||||||
|
|
||||||
const dir = await getWorkingDir(options)
|
const workingDir = await getWorkingDir(options)
|
||||||
|
const dir = workingDir.dir
|
||||||
return {
|
return {
|
||||||
dir: dir,
|
dir: dir,
|
||||||
|
permanent: workingDir.permanent,
|
||||||
pid: path.resolve(dir, 'prosody.pid'),
|
pid: path.resolve(dir, 'prosody.pid'),
|
||||||
error: path.resolve(dir, 'prosody.err'),
|
error: path.resolve(dir, 'prosody.err'),
|
||||||
log: path.resolve(dir, 'prosody.log'),
|
log: path.resolve(dir, 'prosody.log'),
|
||||||
|
@ -6,6 +6,7 @@ interface ProsodyFilePaths {
|
|||||||
config: string
|
config: string
|
||||||
data: string
|
data: string
|
||||||
modules: string
|
modules: string
|
||||||
|
permanent: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
Loading…
Reference in New Issue
Block a user