mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
服务状态(/status)
This commit is contained in:
1 parent
b2989cb9ea
commit
216a4a91e4
19 files changed
+322
-136
No files matched your search
@@ -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 };
|
||||
Reference in new issue
Block a user