Skip to content

Commit

Permalink
Update creator health check return values (#1028)
Browse files Browse the repository at this point in the history
* Updated values

* rename to storagePath
  • Loading branch information
dmanjunath committed Nov 3, 2020
1 parent 8c13e8e commit b2c595d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions creator-node/src/routes/healthCheck.js
Expand Up @@ -4,7 +4,7 @@ const config = require('../config.js')
const versionInfo = require('../../.version.json')
const disk = require('diskusage')

const MAX_DB_CONNECTIONS = 90
const MAX_DB_CONNECTIONS = config.get('dbConnectionPoolMax')
const MAX_DISK_USAGE_PERCENT = 90 // 90%

module.exports = function (app) {
Expand Down Expand Up @@ -100,15 +100,16 @@ module.exports = function (app) {
const maxUsageBytes = parseInt(req.query.maxUsageBytes)
const maxUsagePercent = parseInt(req.query.maxUsagePercent) || MAX_DISK_USAGE_PERCENT

const path = config.get('storagePath')
const { available, total } = await disk.check(path)
const storagePath = config.get('storagePath')
const { available, total } = await disk.check(storagePath)
const usagePercent = Math.round((total - available) * 100 / total)

const resp = {
available: _formatBytes(available),
total: _formatBytes(total),
usagePercent: `${usagePercent}%`,
maxUsagePercent: `${maxUsagePercent}%`
maxUsagePercent: `${maxUsagePercent}%`,
storagePath
}

if (maxUsageBytes) { resp.maxUsage = _formatBytes(maxUsageBytes) }
Expand Down

0 comments on commit b2c595d

Please sign in to comment.