improvement
This commit is contained in:
+1918
-18692
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,24 @@
|
||||
[
|
||||
"cloudflare.com",
|
||||
"postgresql.org",
|
||||
"github.com",
|
||||
"mozilla.org",
|
||||
"amazon.com",
|
||||
"example.invalid",
|
||||
"google.com",
|
||||
"myfakewebsite123.xyz",
|
||||
"postgresql.org",
|
||||
"notarealdomain.test",
|
||||
"github.com",
|
||||
"docker.com",
|
||||
"wikipedia.org",
|
||||
"duckduckgo.com",
|
||||
"nodejs.org",
|
||||
"amns.in",
|
||||
"invalid-site-999.com",
|
||||
"mozilla.org",
|
||||
"amazon.in",
|
||||
"amdocs.com"
|
||||
"thisdoesnotexistabc123.com",
|
||||
"nodejs.org",
|
||||
"amdocs.com",
|
||||
"fake-company-domain.org",
|
||||
"wikipedia.org",
|
||||
"nonexistentdomain987654.net",
|
||||
"duckduckgo.com",
|
||||
"amazon.com",
|
||||
"amns.in",
|
||||
"missingwebsite.fake",
|
||||
"randominvaliddomain12345.io"
|
||||
]
|
||||
@@ -4,6 +4,12 @@ const url_path = path.join(__dirname, "../database", "db.json");
|
||||
|
||||
const StoreRecord = async (urlRecord) => {
|
||||
try {
|
||||
try {
|
||||
await fs.access(url_path);
|
||||
} catch {
|
||||
await fs.writeFile(url_path, "[]");
|
||||
}
|
||||
|
||||
const rawData = await fs.readFile(url_path, "utf8");
|
||||
const data = JSON.parse(rawData);
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ const { StoreRecord } = require("./models/db_store_controller");
|
||||
const { checkUrl } = require("./models/health_status_controller");
|
||||
|
||||
const { init, broadcast } = require("./utils/utils");
|
||||
// const urlPath = "./database/urls.json";
|
||||
const urlPath = path.join(__dirname, "database", "urls.json");
|
||||
dotenv.config();
|
||||
|
||||
@@ -35,11 +34,17 @@ const checkAllUrl = async (Store) => {
|
||||
async function setupWebSocket(wss) {
|
||||
init(wss);
|
||||
let Store = [];
|
||||
checkAllUrl(Store);
|
||||
setInterval(async () => {
|
||||
Store = [];
|
||||
wss.on("connection", (ws) => {
|
||||
checkAllUrl(Store);
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
setInterval(
|
||||
async () => {
|
||||
Store = [];
|
||||
checkAllUrl(Store);
|
||||
},
|
||||
process.env.TIME || 60 * 1000,
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { setupWebSocket };
|
||||
|
||||
Reference in New Issue
Block a user