Bot goes offline after 5 hours

My bot goes down after around 5 hours. How can I make it so it won’t go down? I am using the following code in my server.js file and I already have uptime-robot. I even have keepalive… A node package that will keep the project alive.

const http = require('http');
app.get("/", (request, response) => {
  console.log( + " Ping Received");
setInterval(() => {
}, 180000);
var keepAlive = require("node-keepalive");
keepAlive({}, app);

I don’t know what the issue is. It might also be that my bot is asking too many memory… 82%

UPDATE: I have changed the 180000 from the interval to 2800. I hope this solved the case. I am not sure.

Will keep you updated.

Pinging the project from within the project is kind of unreliable, because if the project goes to sleep once it will never wake up. It’s probably better to set up a cron job that wakes up your project externally every couple of minutes

That is the same what UptimeRobot is doing…

and uptime robot isn’t keeping it awake? hmm then i don’t know

For your memory problem try git prune and git gc in the terminal

I will try, thanks! :smiley:

1 Like

It is, but somehow the bot just goes offline. I hope I could resolve this issue and will let you guys know about it tomorrow as I don’t know if it will stay awake.

It might also be the Discord API rate-limit… Discord has recently updated their API and so they did with the rate-limit. Discord automatically bans bots who override their API rate-limit for a couple of hours.

Nope, the bot keeps going offline after several hours.

After 12 hours glitch automatically shuts off your bot. Maybe this is the case? Alternatively, you might be sending too much pings which is very unlikey. Glitch has a limit of 4000 request per hour.

I am not even exceeding that limit and a week ago it stayed online 23/7…

I think the bot kills itself by sometimes asking more storage… It is kinda strange… It sometimes takes 80% and the other time it only takes 40% or even 70%

Try this instead maybe it will work. but dont delete ur own codes!
const express = require(“express”);
const app = express();
const async = require(“async”);
const http = require(“http”);
app.get("/", (request, response) => {
setInterval(() => {
}, 250000);
(remove keepalive)
and then add the glitch project to uptimerobot from share > live app and copy the link then paste it to uptime robot with http (monitor type http) and monitoring interval 5mins.

So what you’re saying is that I have to remove keepalive and add async…

What does async actually do?

1 Like

Also, welcome to the Glitch community :slight_smile:

1 Like

Async actually is for nothing u can remove it i added it because i wanted to guarantee if any errors pop out. And thank you im welcomed :grinning:

For uptime robot to ping, you would need a webserver as it would show its offline with uptime robot

For me it doesn’t… I just use it with Glitch and so far so good, it works…

From the restrictions page:

Projects sleep after 5 minutes if they are not used, and those running for more than 12 hours are stopped.

But I’ve seen the length of running time vary from 6 hours to 12 hours.

FYI this is 1285 requests per hour :stuck_out_tongue:

So not 4000 requests :grin: