From 5269d17324e4982667d09f773666e145f02f8fa0 Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 25 Mar 2022 12:34:24 +0100 Subject: [PATCH] do not cache host info --- libs/cache.js | 15 --------------- libs/constants.js | 1 - libs/info.js | 22 ++++++++-------------- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/libs/cache.js b/libs/cache.js index cb33ed8..908f921 100644 --- a/libs/cache.js +++ b/libs/cache.js @@ -103,18 +103,6 @@ function setCurrentPedals(value) { setValue(constants.CACHE_PEDALS, value); } -function getInfo() { - return getValue(constants.CACHE_INFO); -} - -function clearInfo() { - resetValue(constants.CACHE_INFO); -} - -function setInfo(value) { - setValue(constants.CACHE_INFO, value); -} - function updateControl(pedalId, control) { if (pedalId === undefined || control === undefined) { return; @@ -162,8 +150,5 @@ module.exports = { getCurrentPedals, clearCurrentPedals, setCurrentPedals, - getInfo, - clearInfo, - setInfo, updateControl } \ No newline at end of file diff --git a/libs/constants.js b/libs/constants.js index cf05f0a..ae7ad23 100644 --- a/libs/constants.js +++ b/libs/constants.js @@ -34,7 +34,6 @@ exports.API_BYPASS_BY_ID = BYPASS + '/' + VARIABLE_ID; exports.API_MIDI = MIDI; exports.API_SYSTEMD = SYSTEMD; -exports.CACHE_INFO = "info"; exports.CACHE_BANKS = "banks"; exports.CACHE_PEDALBOARDS = "pedalboards"; exports.CACHE_PEDALBOARD_DEFAULT = "pedalboard_default"; diff --git a/libs/info.js b/libs/info.js index aead730..c4d47d2 100644 --- a/libs/info.js +++ b/libs/info.js @@ -52,20 +52,16 @@ function getMemoryInfo() { } } -function getTemperature() { - return new Promise(function (resolve, reject) { - commands.execute("vcgencmd", ["measure_temp"]) - .then(resolve) - .catch(reject); - }); +async function getTemperature() { + try { + return commands.execute("vcgencmd", ["measure_temp"]); + } catch (err) { + throw new Error(err); + } } function getHostInfo() { - var info = cache.getInfo(); - if (info != undefined) { - return info; - } - info = { + return { hostname: getHostname(), uptime: getUptime(), load: getLoadAverage(), @@ -76,9 +72,7 @@ function getHostInfo() { kernel: getKernelVersion(), cpu: getCpuInfo(), memory: getMemoryInfo(), - } - cache.setInfo(info); - return info; + }; } module.exports = {