服务状态(/status)

This commit is contained in:
masnn committed 2020-05-31 20:07:52 +08:00
1 parent b2989cb9ea
commit 216a4a91e4
19 files changed
+322 -136

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
const db = require('./db');
const sysinfo = require('../lib/sysinfo');
const coll = db.collection('status');
async function update() {
const [_id, $set] = await sysinfo.update();
await coll.updateOne(
{ _id },
{ $set: { ...$set, updateAt: new Date() } },
{ upsert: true },
);
}
async function postInit() {
const info = await sysinfo.get();
await coll.updateOne(
{ _id: info._id },
{ $set: { ...info, updateAt: new Date() } },
{ upsert: true },
);
setInterval(update, 3 * 60 * 1000);
}
global.Hydro.service.monitor = module.exports = { postInit };