mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-10 15:23:04 -07:00
feat: last online
This commit is contained in:
parent
206d12ded3
commit
40f98cc9df
9 changed files with 82 additions and 64 deletions
|
@ -23,11 +23,15 @@ app.use(express.urlencoded({ extended: false }));
|
|||
if (process.env.ZU_DISABLE_AUTH !== "true") {
|
||||
app.use(
|
||||
bearerToken({
|
||||
headerKey: "Bearer",
|
||||
headerKey: "token",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
console.debug = function () {};
|
||||
}
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV === "production" &&
|
||||
process.env.ZU_SECURE_HEADERS !== "false"
|
||||
|
@ -56,6 +60,18 @@ initAdmin().then(function (admin) {
|
|||
db.defaults({ users: [admin], networks: [] }).write();
|
||||
});
|
||||
|
||||
if (process.env.ZU_LAST_SEEN_FETCH !== "false") {
|
||||
let schedule = process.env.ZU_LAST_SEEN_SCHEDULE || "*/5 * * * *";
|
||||
cron.schedule(schedule, () => {
|
||||
console.debug("Running scheduled job");
|
||||
const networks = db.get("networks").value();
|
||||
networks.forEach((network) => {
|
||||
console.debug("Processing " + network.id);
|
||||
pingAll(network);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const routerAPI = express.Router();
|
||||
const routerController = express.Router();
|
||||
|
||||
|
@ -76,13 +92,4 @@ app.use(async function (err, req, res) {
|
|||
res.status(500).json({ error: "500 Internal server error" });
|
||||
});
|
||||
|
||||
// ping all networks every 5 minutes
|
||||
cron.schedule('5 * * * *', () => {
|
||||
const networks = db.get('networks').value();
|
||||
networks.forEach((network) => {
|
||||
pingAll(network);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
module.exports = app;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue