Better prosody process handling.

This commit is contained in:
John Livingston 2021-04-14 17:55:26 +02:00
parent 63112df21a
commit faa12de768

View File

@ -122,13 +122,25 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
// launch prosody
logger.info('Going to launch prosody')
child_process.exec('prosody', {
const prosody = child_process.exec('prosody', {
cwd: filePaths.dir,
env: {
...process.env,
PROSODY_CONFIG: filePaths.config
}
})
prosody.stdout?.on('data', (data) => {
logger.debug(`Prosody stdout: ${data as string}`)
})
prosody.stderr?.on('data', (data) => {
logger.error(`Prosody stderr: ${data as string}`)
})
prosody.on('close', (code) => {
logger.info(`Prosody process closed all stdio with code ${code ?? 'null'}`)
})
prosody.on('exit', (code) => {
logger.info(`Prosody process exited with code ${code ?? 'null'}`)
})
async function sleep (ms: number): Promise<any> {
return new Promise((resolve) => {