Implements #37: diagnostic tools includes last lines from prosody error log files.
This commit is contained in:
parent
6f47ffe19d
commit
059c6522b6
@ -49,6 +49,7 @@ Peertube image.
|
|||||||
|
|
||||||
* Fix «autocolor» mecanism when no color provided (raised an error).
|
* Fix «autocolor» mecanism when no color provided (raised an error).
|
||||||
* Fix #73: deleted message are shown when loading history.
|
* Fix #73: deleted message are shown when loading history.
|
||||||
|
* Implements #37: diagnostic tools includes last lines from prosody error log files.
|
||||||
|
|
||||||
## 5.7.1
|
## 5.7.1
|
||||||
|
|
||||||
|
@ -23,9 +23,11 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
|
|||||||
// Testing the prosody config file.
|
// Testing the prosody config file.
|
||||||
let prosodyPort: string
|
let prosodyPort: string
|
||||||
let prosodyHost: string
|
let prosodyHost: string
|
||||||
|
let prosodyErrorLogPath: string
|
||||||
try {
|
try {
|
||||||
const wantedConfig = await getProsodyConfig(options)
|
const wantedConfig = await getProsodyConfig(options)
|
||||||
const filePath = wantedConfig.paths.config
|
const filePath = wantedConfig.paths.config
|
||||||
|
prosodyErrorLogPath = wantedConfig.paths.error
|
||||||
|
|
||||||
result.messages.push(`Prosody will run on port '${wantedConfig.port}'`)
|
result.messages.push(`Prosody will run on port '${wantedConfig.port}'`)
|
||||||
prosodyPort = wantedConfig.port
|
prosodyPort = wantedConfig.port
|
||||||
@ -163,6 +165,27 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checking if there is a Prosody error log, and returning last lines.
|
||||||
|
try {
|
||||||
|
await fs.promises.access(prosodyErrorLogPath, fs.constants.R_OK) // throw an error if file does not exist.
|
||||||
|
result.messages.push(`The prosody error log (${prosodyErrorLogPath}) exists`)
|
||||||
|
const errorLogContent = await fs.promises.readFile(prosodyErrorLogPath, {
|
||||||
|
encoding: 'utf-8'
|
||||||
|
})
|
||||||
|
|
||||||
|
let logLines = errorLogContent.split(/\r?\n/)
|
||||||
|
if (logLines.length > 50) {
|
||||||
|
logLines = logLines.slice(-50)
|
||||||
|
}
|
||||||
|
|
||||||
|
result.debug.push({
|
||||||
|
title: 'Prosody error log (last 50 lines)',
|
||||||
|
message: logLines.join('\n')
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
// Error should be because file does not exists. This is not an error case, just ignoring.
|
||||||
|
}
|
||||||
|
|
||||||
result.ok = true
|
result.ok = true
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user