WIP.
This commit is contained in:
parent
cc21305f6a
commit
da37e539f7
@ -1,4 +1,5 @@
|
|||||||
import { getProsodyConfigContent, getProsodyConfigPath, getWorkingDir } from '../prosody/config'
|
import { getProsodyConfigContent, getProsodyConfigPath, getWorkingDir } from '../prosody/config'
|
||||||
|
import { testProsodyCorrectlyRunning } from '../prosody/ctl'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: these tests should also be in testProsodyCorrectlyRunning
|
||||||
// Testing the prosody config file.
|
// Testing the prosody config file.
|
||||||
try {
|
try {
|
||||||
const filePath = await getProsodyConfigPath(options)
|
const filePath = await getProsodyConfigPath(options)
|
||||||
@ -34,6 +36,14 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isCorrectlyRunning = await testProsodyCorrectlyRunning(options)
|
||||||
|
if (isCorrectlyRunning.messages.length) {
|
||||||
|
result.messages.push(...isCorrectlyRunning.messages)
|
||||||
|
}
|
||||||
|
if (!isCorrectlyRunning.ok) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
result.ok = true
|
result.ok = true
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,27 @@
|
|||||||
import { writeProsodyConfig } from './config'
|
import { writeProsodyConfig } from './config'
|
||||||
|
|
||||||
|
interface ProsodyCorrectlyRunning {
|
||||||
|
ok: boolean
|
||||||
|
messages: string[]
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param options
|
* @param options
|
||||||
* @returns true if prosody is running with up to date parameters. A string array of messages otherwise.
|
* @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
|
const { peertubeHelpers } = options
|
||||||
peertubeHelpers.logger.info('Checking if Prosody is correctly running')
|
peertubeHelpers.logger.info('Checking if Prosody is correctly running')
|
||||||
|
const result: ProsodyCorrectlyRunning = {
|
||||||
|
ok: false,
|
||||||
|
messages: []
|
||||||
|
}
|
||||||
|
|
||||||
|
result.messages.push('Pid file not found')
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
peertubeHelpers.logger.error('testProsodyCorrectlyRunning not implemented yet.')
|
peertubeHelpers.logger.error('testProsodyCorrectlyRunning not implemented yet.')
|
||||||
return ['Process not found']
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureProsodyRunning (options: RegisterServerOptions): Promise<void> {
|
async function ensureProsodyRunning (options: RegisterServerOptions): Promise<void> {
|
||||||
@ -24,11 +35,11 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
|
|||||||
}
|
}
|
||||||
|
|
||||||
const r = await testProsodyCorrectlyRunning(options)
|
const r = await testProsodyCorrectlyRunning(options)
|
||||||
if (r === true) {
|
if (r.ok) {
|
||||||
logger.info('Prosody is already running correctly')
|
logger.info('Prosody is already running correctly')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.info('Prosody is not running correctly: ' + r.join(', '))
|
logger.info('Prosody is not running correctly: ' + r.messages.join(', '))
|
||||||
// Shutting down...
|
// Shutting down...
|
||||||
await ensureProsodyNotRunning(options)
|
await ensureProsodyNotRunning(options)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user