Fix reload
This commit is contained in:
parent
df6741b452
commit
3ed7d3aa58
14
index.js
14
index.js
|
@ -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");
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue