Download server.js from Hakidev/gonu: direct link, hf CLI and curl.
- Browser
- Download file 860 Bytes
-
https://huggingface.co/spaces/Hakidev/gonu/resolve/main/server.js
- Command line
-
hf download hf://spaces/Hakidev/gonu/server.js
-
curl -L -o server.js https://huggingface.co/spaces/Hakidev/gonu/resolve/main/server.js
860 Bytes
| 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); |