chore: more stats info

pull/115/head
Amio 2018-08-16 13:14:59 +08:00
rodzic 02b9a0dd9f
commit e65c0acd2a
2 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -33,7 +33,10 @@ const apiHandlers = Object.entries(liveFunctions).map(([name, fn]) => {
})
const indexContent = fs.readFileSync(path.join(__dirname, 'index-api.md'), 'utf8')
const serveIndex = (req, res) => send(res, 200, indexContent)
const serveIndex = (req, res) => {
res.setHeader('Cache-Control', 'public, max-age=60, s-maxage=86400')
send(res, 200, indexContent)
}
module.exports = router()(
get('/', serveIndex),

Wyświetl plik

@ -5,8 +5,14 @@ const livePool = require('./live-pool.js')
module.exports = async (req, res) => {
const [githubRateLimit] = await Promise.all([getGithubRateLimit()])
const fetching = Object.values(livePool.list()).filter(Boolean).length
const cpuUsage = process.cpuUsage()
const memUsage = process.memoryUsage()
send(res, 200, { githubRateLimit, fetching })
const stats = { githubRateLimit, fetching, cpuUsage, memUsage }
res.setHeader('Content-Type', 'application/json; charset=utf-8')
res.setHeader('Cache-Control', 'public, max-age=1, s-maxage=1')
send(res, 200, JSON.stringify(stats, null, 2))
}
const getGithubRateLimit = () => {