Little improvements

This commit is contained in:
La Programmatrice Verde
2025-11-21 21:36:49 +01:00
parent da58b9c573
commit b8db372484
5 changed files with 30 additions and 11 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/log

View File

@@ -2,7 +2,7 @@ const axios = require("axios");
const shared = require("./shared.js");
const { Log } = require("./logs.js");
let hostIDs = [];
var monitorInterval;
let monitorInterval;
async function Monitoring() {
await initHostList();
@@ -18,9 +18,9 @@ async function Monitoring() {
}
async function Request() {
var hosts = [];
let hosts = [];
for (const element of hostIDs) {
var obj = {
let obj = {
id: element,
[element]: await isConnected(element),
};
@@ -75,9 +75,14 @@ async function initHostList() {
},
}
);
for (const host of response.data) {
hostIDs.push(host.id);
}
/*
response.data.forEach((host) => {
hostIDs.push(host.id);
});
*/
} catch (error) {
Log(
`[${shared.now()}] Errore nella verifica e aggiunta al monitoraggio di un host.`
@@ -170,9 +175,16 @@ async function initHostList() {
Authorization: `Token ${shared.getToken()}`,
},
});
for (const element of response.data) {
hostIDs.push(element.id);
}
/*
response.data.forEach((element) => {
hostIDs.push(element.id);
});
*/
} catch (error) {
Log(`[${shared.now()}] Errore nel tentativo di reperire tutti i peer.`);
Log(`[${shared.now()}] ${error}`);
@@ -182,9 +194,15 @@ async function initHostList() {
}
Log(`[${shared.now()}] ID rilevati:`);
for (const element of hostIDs) {
Log(`[${shared.now()}] ${element}`);
}
/*
hostIDs.forEach((element) => {
Log(`[${shared.now()}] ${element}`);
});
*/
}
module.exports = { Monitoring };

View File

@@ -11,9 +11,9 @@ shared.eventEmitter = eventEmitter;
let baseToken = process.env.BASE_TOKEN;
shared.setToken(baseToken);
global.minute = 1000 * 60;
global.hour = minute * 60;
global.day = hour * 24;
globalThis.minute = 1000 * 60;
globalThis.hour = minute * 60;
globalThis.day = hour * 24;
app.listen(port, () => {
Log(`[${shared.now()}] Il server è online sulla porta ${port}`);

View File

@@ -1,9 +1,9 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");
const shared = require("./shared.js");
let logFile;
var dir = 'log/';
let dir = 'log/';
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);

View File

@@ -1,6 +1,6 @@
const dayjs = require("dayjs");
var utc = require("dayjs/plugin/utc");
var timezone = require("dayjs/plugin/timezone");
let utc = require("dayjs/plugin/utc");
let timezone = require("dayjs/plugin/timezone");
module.exports = {
token: "",