Not letting the App go down


#1

I read the FAQ section and noticed this points

  • Projects created by anonymous users expire after 5 days (login via GitHub or Facebook to keep your projects around).
  • Projects sleep after 5 minutes if they are not used.
  • Projects are limited to 4000 requests per hour, with a burst of 4000 requests (subsequent requests will return a 429 “Too Many Requests” response).
  • Projects have a limit of 128MB of space on the container (though things written to ‘/tmp’ don’t count towards that, and we use compression to squeeze the most out of that space). As well as up to 512MB of assets storage.
  • Projects only show up to 100 files in the file tree, the rest get hidden from view but still exist. Using .gitignore to temporarily remove some files from view can help work around this.
  • Similarly, files above 200kb are hidden from the file tree (but still exist), and you’re unable to paste data into the editor above that size too.

I am good with every point except the second point

  • Projects sleep after 5 minutes if they are not used.

Is it somehow possible that the project wont sleep even after 5 mins.
I am making a discord bot and I dont really want that to happen.
Every other points are fine with me though.

Hoping to see a reply about this as soon as possible :smiley:


#2

Apps sleeping is a large reason why we can offer the Glitch service for free, so it’s not something we can turn off. However, we accept that for some use-cases, like bots with no webhooks support, that’s not ideal. It’s possible to expose a route in your app that a web cron service or uptime monitoring service can hit and cause your bot to wake. Doing that every 5 mins or so should do what you want.


#3

Does that means,
If I call my bot codes (using callback or timer in the codes) like every 5 min, it wont go down ?
but yeah with that 4000 request right ?


#4

Yes, and it’ll be ok - the limit is 4000 requests per hour.


#5

Well I am not sure about how to do it again,
I tried making the app busy with some tasks like
setInterval(…,…)
That indeed kept the app busy,
but again it went off after 30 mins.

If you could somehow help me with it. :smiley:

And if futher details help then my app is not a web app insted some worker app (as said in heroku)
As its a discord bot


#6

Hi @Froosty,

the only way to keep your app “awake” is to hit one of its endpoints. So even if your app is a worker, you can start a simple http server and then you can hit your app as Gareth described.


#7

Thanks for your answer,
but In the mean time I would like to ask sorry,
I am new to these stuffs,
mostly the running web and worker apps in VPS.

So if you could help me with it, or if any tutorial for that.
It would be very thankful of you. :smiley:


Help with my bot code
#8

can someone literally help me with it,
As I said I am new to these stuffs :unamused:


#9

If you’re just using setInterval() to try to call code inside your app, that’s not going to keep it awake. What you would need to do is use setInterval() to cause a delay, and then in the code that runs after the delay, you need to do an HTTP request to one of your own app’s endpoints. That will keep Glitch from shutting the app down.


#10

Here’s an example project that works using this approach: https://glitch.com/edit/#!/twitter-dm-quiz-bot-polling. In it, it exposes the /tweet route to check for new DMs and then sends the appropriate response. You can use uptimerobot.com or a similar service to poll this /tweet endpoint.


#11

I had already known that info @Tim, I was just looking for how to do it. :smiley:
and thanks to @Gareth I have got the info now, just need to check it out though.


#12

Hmm I preety much looked into that example @Gareth but there are few problems I am facing

  • firstly my app isnt opening around https://brass-noodle.glitch.me/, here is my app https://glitch.com/edit/#!/twitter-dm-quiz-bot-polling?path=server.js:1:0
    Deleted my app so will be checking out from start and updating the link soon
    (I dunno if this can cause trouble to what I am doing or not but still It should have been opened around there, and also I am not getting any errors in the log)

  • secondly I am really confused about things done there,
    Like is some code inside server.js responsible for keeping the app safe from shutting down ?

Please help me with it,
The more I look into it and more I get confused :frowning:


#13

Here’s the solution I provided which should work for any such app that doesn’t actually need any front-facing app (but hey express.js is already installed so why not)

const http = require('http');
const express = require('express');
const app = express();
app.get("/", (request, response) => response.sendStatus(200));
app.listen(process.env.PORT);
setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);

Should work well enough without the need for any other service. Still testing, though.