Fix Peertube server crash when prosody is not installed.

This commit is contained in:
John Livingston 2021-04-18 17:48:21 +02:00
parent bb1adf3fa9
commit 079332733a
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## v2.0.3
* Fix Peertube server crash when prosody is not installed
## v2.0.2 ## v2.0.2
* Trying to fix dependencies installation problems * Trying to fix dependencies installation problems

View File

@ -17,7 +17,7 @@ async function prosodyCtl (options: RegisterServerOptions, command: string): Pro
if (!/^\w+$/.test(command)) { if (!/^\w+$/.test(command)) {
throw new Error(`Invalid prosodyctl command '${command}'`) throw new Error(`Invalid prosodyctl command '${command}'`)
} }
return new Promise((resolve) => { return new Promise((resolve, reject) => {
let d: string = '' let d: string = ''
let e: string = '' let e: string = ''
let m: string = '' let m: string = ''
@ -41,6 +41,7 @@ async function prosodyCtl (options: RegisterServerOptions, command: string): Pro
e += data as string e += data as string
m += data as string m += data as string
}) })
spawned.on('error', reject)
spawned.on('exit', (code) => { spawned.on('exit', (code) => {
resolve({ resolve({
code: code, code: code,
@ -172,6 +173,9 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
prosody.stderr?.on('data', (data) => { prosody.stderr?.on('data', (data) => {
logger.error(`Prosody stderr: ${data as string}`) logger.error(`Prosody stderr: ${data as string}`)
}) })
prosody.on('error', (error) => {
logger.error(`Prosody exec error: ${JSON.stringify(error)}`)
})
prosody.on('close', (code) => { prosody.on('close', (code) => {
logger.info(`Prosody process closed all stdio with code ${code ?? 'null'}`) logger.info(`Prosody process closed all stdio with code ${code ?? 'null'}`)
}) })