mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
26 lines
627 B
JavaScript
26 lines
627 B
JavaScript
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 };
|