I’m running a Discord bot, and I need Uptime Robot to keep the project up. My UptimeRobot is saying that my project (oregon-relay, it’s on private)'s webpage cannot be found. I have tried to change the settings for the URL in UptimeRobot, but it still doesn’t work. I tried going to its webpage, but it says “Cannot GET /”.
EDIT: Bot still works, but I think it goes down after 12 hours.
You need to set an express server to make an http request and response.
add this line to your bot.js file
require('./express/server')
Then add the file express/server.js
const http = require('http');
const express = require('express');
const app = express();
// Ping request
app.get('/', (req, res) => {
console.log(new Date() + ' Ping!'); // You can comment this line if you don't want console.log
res.status(200).send('Ping!');
});
// Listener
const listener = app.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
// Auto-ping interval
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
This file make an express server with a get request to your http://project-name.glitch.me and set an auto-ping every 5 minutes. This is good if UptimeRobot doesn’t work.
Finally you set your UptimeRobot to the address http://project-name.glitch.me and you have to start getting 200 status responses, no errors.