Goodboy1132/Privatelife
0
1const http = require('http');2const { exec } = require('child_process');3const PORT = 7860;4const RESTART_INTERVAL_MS = 5 * 60 * 60 * 1000; // 5 hours in milliseconds5 6const startServer = () => {7 const server = http.createServer((req, res) => {8 res.writeHead(200, { 'Content-Type': 'text/html' });9 res.end('<html><body><b><marquee>KING Alya<marquee></b></body></html>');10 });11 12 server.listen(PORT, () => {13 console.log(`Server listening on port ${PORT}`);14 });15 16 return server;17};18 19let server = startServer();20 21// Function to restart the server22const restartServer = () => {23 console.log('Restarting server...');24 25 server.close(() => {26 console.log('Server stopped.');27 server = startServer();28 });29};30 31// Set up the interval to restart the server every 5 hours32setInterval(restartServer, RESTART_INTERVAL_MS);33 34// Error handling35process.on('uncaughtException', (err) => {36 console.error('Uncaught Exception:', err);37 restartServer();38});39 40process.on('unhandledRejection', (reason, promise) => {41 console.error('Unhandled Rejection at:', promise, 'reason:', reason);42 restartServer();43});