From 4ed640f497f28c3ef2387fe7b675b103d1178d35 Mon Sep 17 00:00:00 2001 From: Xargana Date: Wed, 26 Mar 2025 17:59:23 +0300 Subject: [PATCH] aa --- status/server.js | 59 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/status/server.js b/status/server.js index f93245f..a806f69 100644 --- a/status/server.js +++ b/status/server.js @@ -6,41 +6,40 @@ const app = express(); const PORT = 2589; // Set the API to run on port 2589 const CHECK_INTERVAL = 30 * 1000; // Check every 30 seconds -const REMOTE_SERVER = "https://example.com"; // Change this to the server you want to check +const REMOTE_SERVER = "https://srv.xargana.com"; // Change this to the server you want to check let serverStatus = { online: false, - lastChecked: null, - responseTime: null, - }; + lastChecked: null, + responseTime: null, +}; - // Enable CORS to allow requests from other domains - app.use(cors()); +// Enable CORS to allow requests from other domains +app.use(cors()); - // Function to check server status - async function checkServer() { - const startTime = Date.now(); - try { - await axios.get(REMOTE_SERVER, { timeout: 5000 }); // 5-second timeout - serverStatus.online = true; - } catch (error) { - serverStatus.online = false; - } - serverStatus.responseTime = Date.now() - startTime; - serverStatus.lastChecked = new Date().toISOString(); - } +// Function to check server status +async function checkServer() { + const startTime = Date.now(); + try { + await axios.get(REMOTE_SERVER, { timeout: 5000 }); // 5-second timeout + serverStatus.online = true; + } catch (error) { + serverStatus.online = false; + } + serverStatus.responseTime = Date.now() - startTime; + serverStatus.lastChecked = new Date().toISOString(); +} - // Run the check every 30 seconds - setInterval(checkServer, CHECK_INTERVAL); - checkServer(); // Initial check +// Run the check every 30 seconds +setInterval(checkServer, CHECK_INTERVAL); +checkServer(); // Initial check - // API route to get the server status - app.get("/status", (req, res) => { - res.json(serverStatus); - }); +// API route to get the server status +app.get("/status", (req, res) => { + res.json(serverStatus); +}); - // Start the server on port 2589 - app.listen(PORT, () => { - console.log(`API running at https://blahaj.tr:${PORT}`); - }); - \ No newline at end of file +// Start the server on port 2589 +app.listen(PORT, () => { + console.log(`API running at https://localhost:${PORT}`); +});