Fix reload

This commit is contained in:
Christopher Cookman 2024-12-19 15:38:22 -07:00
parent df6741b452
commit 3ed7d3aa58

View file

@ -72,21 +72,17 @@ const json2csv = (obj) => { // Specifically for CDR
const reload = () => { const reload = () => {
// We're gonna start converting all the old gql commands to using mysql `system fwconsole reload` query // We're gonna start converting all the old gql commands to using mysql `system fwconsole reload` query
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
sshConn.exec('fwconsole reload', (err, stream) => { sshConn.exec('fwconsole reload --json', (err, stream) => {
if (err) { if (err) {
reject(err); reject(err);
} }
stream.on('data', (data) => { stream.on('data', (data) => {
// is there a way to send this data without resolving the promise? // is there a way to send this data without resolving the promise?
console.log(data.toString()); dt = JSON.parse(data.toString())
}); if (dt.message == "Reload Complete") {
stream.on('exit', (code, signal) => { resolve(dt);
if (code == 0) {
resolve(code);
} else {
reject("Error reloading FreePBX");
} }
}) });
}); });
}); });
} }