smc-hub
Version:
CoCalc: Backend webserver component
28 lines • 726 B
JavaScript
/*
Periodically update the stats in the database.
*/
var _a;
var postgres = require("smc-hub/postgres");
var ttl = parseInt((_a = process.env.STATS_TTL_S) !== null && _a !== void 0 ? _a : "300");
var db = postgres.db({
ensure_exists: false,
});
function update() {
console.log("updating stats...");
db.get_stats({
update: true,
ttl: ttl,
cb: function (err, stats) {
if (err) {
throw Error("failed to update stats -- " + err);
}
else {
console.log("updated stats", stats);
}
setTimeout(update, ttl * 1000);
},
});
}
update();
//# sourceMappingURL=stats-updater.js.map