This commit is contained in:
John Livingston
2021-04-13 18:00:45 +02:00
parent cc21305f6a
commit da37e539f7
2 changed files with 25 additions and 4 deletions

View File

@ -1,16 +1,27 @@
import { writeProsodyConfig } from './config'
interface ProsodyCorrectlyRunning {
ok: boolean
messages: string[]
}
/**
* @param options
* @returns true if prosody is running with up to date parameters. A string array of messages otherwise.
*/
async function testProsodyCorrectlyRunning (options: RegisterServerOptions): Promise<true | string[]> {
async function testProsodyCorrectlyRunning (options: RegisterServerOptions): Promise<ProsodyCorrectlyRunning> {
const { peertubeHelpers } = options
peertubeHelpers.logger.info('Checking if Prosody is correctly running')
const result: ProsodyCorrectlyRunning = {
ok: false,
messages: []
}
result.messages.push('Pid file not found')
// TODO
peertubeHelpers.logger.error('testProsodyCorrectlyRunning not implemented yet.')
return ['Process not found']
return result
}
async function ensureProsodyRunning (options: RegisterServerOptions): Promise<void> {
@ -24,11 +35,11 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
}
const r = await testProsodyCorrectlyRunning(options)
if (r === true) {
if (r.ok) {
logger.info('Prosody is already running correctly')
return
}
logger.info('Prosody is not running correctly: ' + r.join(', '))
logger.info('Prosody is not running correctly: ' + r.messages.join(', '))
// Shutting down...
await ensureProsodyNotRunning(options)