WIP.
This commit is contained in:
		| @ -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 | ||||
| } | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user