From d4d3316d189f56c9805a4304666d98a9eabe0bba Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 27 Jul 2018 17:43:04 +0900 Subject: [PATCH] :sparkles: --- src/daemons/server-stats.ts | 50 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/daemons/server-stats.ts b/src/daemons/server-stats.ts index afedafb29..d2c6e3229 100644 --- a/src/daemons/server-stats.ts +++ b/src/daemons/server-stats.ts @@ -18,10 +18,10 @@ export default function() { }); async function tick() { - const cpu = await cpuUsage(); - const freemem = await freeMem(); + const cpu = await cpuUsage(); + const freemem = await freeMem(); const totalmem = await totalMem(); - const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/'); + const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/'); const stats = { cpu_usage: cpu, @@ -45,33 +45,31 @@ export default function() { // CPU STAT async function cpuUsage() { - try { - const data = await sysUtils.currentLoad(); - return Math.floor(data.currentload); - } - catch(error) { - console.error(error); - } + try { + const data = await sysUtils.currentLoad(); + return Math.floor(data.currentload); + } catch (error) { + console.error(error); + throw error; + } } -// MEMORY(excl buffer + cache) STAT +// MEMORY(excl buffer + cache) STAT async function freeMem() { - try { - const data = await sysUtils.mem(); - return data.active; - } - catch(error) { - console.error(error); - } + try { + const data = await sysUtils.mem(); + return data.active; + } catch (error) { + console.error(error); + } } // TOTAL MEMORY STAT async function totalMem() { - try { - const data = await sysUtils.mem(); - return data.total; - } - catch(error) { - console.error(error); - } -} \ No newline at end of file + try { + const data = await sysUtils.mem(); + return data.total; + } catch (error) { + console.error(error); + } +}