Create server.js
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243const http = require('http');const { exec } = require('child_process');const PORT = 7860;const RESTART_INTERVAL_MS = 5 * 60 * 60 * 1000; // 5 hours in milliseconds
const startServer = () => { const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/html' }); res.end('<html><body><b><marquee>KING Alya<marquee></b></body></html>'); });
server.listen(PORT, () => { console.log(`Server listening on port ${PORT}`); });
return server;};
let server = startServer();
// Function to restart the serverconst restartServer = () => { console.log('Restarting server...');
server.close(() => { console.log('Server stopped.'); server = startServer(); });};
// Set up the interval to restart the server every 5 hourssetInterval(restartServer, RESTART_INTERVAL_MS);
// Error handlingprocess.on('uncaughtException', (err) => { console.error('Uncaught Exception:', err); restartServer();});
process.on('unhandledRejection', (reason, promise) => { console.error('Unhandled Rejection at:', promise, 'reason:', reason); restartServer();});server.jsAdded+43