Spaces:
Paused

File size: 860 Bytes
babaa59
67c0da7
babaa59
67c0da7
babaa59
 
67c0da7
babaa59
 
67c0da7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
babaa59
67c0da7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const http = require('http');
const { exec } = require('child_process');

// Create HTTP server
http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('<html><body><b><marquee>KING Haki</marquee></b></body></html>');
}).listen(7860, () => {
  console.log('Server listening on port 7860');
});

// Function to restart the bot
function restartBot() {
  console.log("Restarting bot...");
  exec("pm2 restart bot", (error, stdout, stderr) => {
    if (error) {
      console.error(`Error while restarting the bot: ${error.message}`);
      return;
    }
    if (stderr) {
      console.error(`Stderr: ${stderr}`);
      return;
    }
    console.log(`Bot restarted successfully: ${stdout}`);
  });
}

// Set an interval to restart the bot every 5 hours (5 * 60 * 60 * 1000 = 18000000 ms)
setInterval(restartBot, 18000000);