Promisify admin-support

This commit is contained in:
goga-m 2017-11-14 17:52:50 +02:00 committed by Josh Harvey
parent e998e84cca
commit 39f9848ca1
3 changed files with 6 additions and 13 deletions

View file

@ -340,5 +340,5 @@ function run () {
const supportLog = `lamassu-support-server listening on port ${supportPort}` const supportLog = `lamassu-support-server listening on port ${supportPort}`
webServer.listen(serverPort, () => console.log(serverLog)) webServer.listen(serverPort, () => console.log(serverLog))
supportServer.run(supportPort, () => console.log(supportLog)) supportServer.run(supportPort).then(console.log(supportLog))
} }

View file

@ -57,9 +57,11 @@ app.post('/api/support_logs', (req, res, next) => {
.catch(next) .catch(next)
}) })
function run (port, cb) { function run (port) {
return new Promise((resolve, reject) => {
const webServer = https.createServer(certOptions, app) const webServer = https.createServer(certOptions, app)
webServer.listen(port || 443, cb) webServer.listen(port, resolve)
})
} }
module.exports = { run } module.exports = { run }

View file

@ -69,15 +69,6 @@ function update (deviceId, logLines) {
* @returns {array} Array of logs for the requested machinej * @returns {array} Array of logs for the requested machinej
*/ */
function getMachineLogs (deviceId, until = new Date().toISOString()) { function getMachineLogs (deviceId, until = new Date().toISOString()) {
const defaults = {
logs: [],
currentMachine: {
name: '',
deviceId: ''
}
}
if (!deviceId) return defaults
const sql = `select id, log_level, timestamp, message from logs const sql = `select id, log_level, timestamp, message from logs
where device_id=$1 where device_id=$1
and timestamp <= $3 and timestamp <= $3