From da37e539f737c84e2f471fd0b57ff47190c66606 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Tue, 13 Apr 2021 18:00:45 +0200 Subject: [PATCH] WIP. --- server/lib/diagnostic/prosody.ts | 10 ++++++++++ server/lib/prosody/ctl.ts | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/server/lib/diagnostic/prosody.ts b/server/lib/diagnostic/prosody.ts index 2334582d..f14859b2 100644 --- a/server/lib/diagnostic/prosody.ts +++ b/server/lib/diagnostic/prosody.ts @@ -1,4 +1,5 @@ import { getProsodyConfigContent, getProsodyConfigPath, getWorkingDir } from '../prosody/config' +import { testProsodyCorrectlyRunning } from '../prosody/ctl' import { newResult, TestResult } from './utils' import * as fs from 'fs' @@ -14,6 +15,7 @@ export async function diagProsody (test: string, options: RegisterServerOptions) return result } + // FIXME: these tests should also be in testProsodyCorrectlyRunning // Testing the prosody config file. try { const filePath = await getProsodyConfigPath(options) @@ -34,6 +36,14 @@ export async function diagProsody (test: string, options: RegisterServerOptions) return result } + const isCorrectlyRunning = await testProsodyCorrectlyRunning(options) + if (isCorrectlyRunning.messages.length) { + result.messages.push(...isCorrectlyRunning.messages) + } + if (!isCorrectlyRunning.ok) { + return result + } + result.ok = true return result } diff --git a/server/lib/prosody/ctl.ts b/server/lib/prosody/ctl.ts index 3560abe7..a11c66a0 100644 --- a/server/lib/prosody/ctl.ts +++ b/server/lib/prosody/ctl.ts @@ -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 { +async function testProsodyCorrectlyRunning (options: RegisterServerOptions): Promise { 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 { @@ -24,11 +35,11 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise