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 = () => {
|
||||
// We're gonna start converting all the old gql commands to using mysql `system fwconsole reload` query
|
||||
return new Promise((resolve, reject) => {
|
||||
sshConn.exec('fwconsole reload', (err, stream) => {
|
||||
sshConn.exec('fwconsole reload --json', (err, stream) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
stream.on('data', (data) => {
|
||||
// is there a way to send this data without resolving the promise?
|
||||
console.log(data.toString());
|
||||
});
|
||||
stream.on('exit', (code, signal) => {
|
||||
if (code == 0) {
|
||||
resolve(code);
|
||||
} else {
|
||||
reject("Error reloading FreePBX");
|
||||
dt = JSON.parse(data.toString())
|
||||
if (dt.message == "Reload Complete") {
|
||||
resolve(dt);
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue