Fix prosody exec call.
This commit is contained in:
parent
8a73d93aac
commit
63112df21a
@ -1,10 +1,7 @@
|
|||||||
import { getProsodyFilePaths, writeProsodyConfig } from './config'
|
import { getProsodyFilePaths, writeProsodyConfig } from './config'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as util from 'util'
|
|
||||||
import * as child_process from 'child_process'
|
import * as child_process from 'child_process'
|
||||||
|
|
||||||
const exec = util.promisify(child_process.exec)
|
|
||||||
|
|
||||||
interface ProsodyRunning {
|
interface ProsodyRunning {
|
||||||
ok: boolean
|
ok: boolean
|
||||||
messages: string[]
|
messages: string[]
|
||||||
@ -125,16 +122,39 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
|
|||||||
|
|
||||||
// launch prosody
|
// launch prosody
|
||||||
logger.info('Going to launch prosody')
|
logger.info('Going to launch prosody')
|
||||||
await exec('prosody', {
|
child_process.exec('prosody', {
|
||||||
cwd: filePaths.dir,
|
cwd: filePaths.dir,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
PROSODY_CONFIG: filePaths.config
|
PROSODY_CONFIG: filePaths.config
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
logger.info('Verifying prosody is launched')
|
|
||||||
const status = await prosodyCtl(options, 'status', true)
|
async function sleep (ms: number): Promise<any> {
|
||||||
logger.info(`Prosody status: ${status}`)
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, ms)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
logger.info('Waiting for the prosody process to launch')
|
||||||
|
let count: number = 0
|
||||||
|
let processStarted: boolean = false
|
||||||
|
while (!processStarted && count < 5) {
|
||||||
|
count++
|
||||||
|
await sleep(500)
|
||||||
|
logger.info('Verifying prosody is launched')
|
||||||
|
try {
|
||||||
|
const status = await prosodyCtl(options, 'status', true)
|
||||||
|
logger.info(`Prosody status: ${status}`)
|
||||||
|
processStarted = true
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn(`Prosody status: ${error as string}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!processStarted) {
|
||||||
|
logger.error('It seems that the Prosody process is not up')
|
||||||
|
} else {
|
||||||
|
logger.info('Prosody is running')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureProsodyNotRunning (options: RegisterServerOptions): Promise<void> {
|
async function ensureProsodyNotRunning (options: RegisterServerOptions): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user