app.get('/stats', function __sendStats(req, res) { var mem = process.memoryUsage(); // convert to MB mem.heapTotal = utils.round(mem.heapTotal / 1024.0 / 1024.0); mem.heapUsed = utils.round(mem.heapUsed / 1024.0 / 1024.0); mem.rss = utils.round(mem.rss / 1024.0 / 1024.0) + '(= actual physical RAM)'; var uptimeH = utils.round(process.uptime() / 60.0 / 60.0); var uptimeM = utils.round(process.uptime() / 60.0); var json = { pid : process.pid, memory: mem, uptime: uptimeH + ' hours (= ' + uptimeM + ' minutes)', customMsg: 'AtOneGo API v' + pjson.version + ' - Environment: ' + ENV }; return res.json(json, 200); });
// Format a size to px or em function cssSize(size, fontSize) { let unit = `px` if (_.isNumber(fontSize) && fontSize > 0) { unit = `em` } if (unit === `px`) { return size + `px` } return _.round(size / fontSize, 3) + `em` }
* Jacob Andreas * * Populates a Redis database for use with Canvas City. * * THIS WILL FLUSH THE DATABASE! */ var redis = require('redis').createClient(); var cc = require(__dirname + '/public/cc-common.js'); cells = []; // create keys for all the map cells in the world for(lat = cc.MAP_SOUTH; lat <= cc.MAP_NORTH; lat += cc.MAP_PRECISION) { for(lng = cc.MAP_WEST; lng < cc.MAP_EAST; lng += cc.MAP_PRECISION) { key = 'cell:' + cc.round(lat) + ':' + cc.round(lng); cells.push(key); } } // clear the datastore redis.flushall(); // create lists of zeroes for every cell in the world multi = redis.multi(); cells.forEach(function(cell) { for(x = 0; x < cc.CELL_COLS; x++) { for(y = 0; y < cc.CELL_ROWS; y++) { multi.lpush(cell, 0); } }