But removing it makes my project damn slow!! I used other way to keep my project like using websocket. But still it is not working as expected it is so slow.
EDIT BY ADMIN: I modified your post so that the code is well formatted.
Your node.js app needs something to keep it alive, some sort of event that has to happen in next tick. For example when you’re using an interval to keep it alive which makes the node.js process always have a task to do.
Here’s an example of an app that will live forever:
// Create an interval to keep the process alive.
const interval = setInterval(() => {
// So, the deal is, nothing really needs to happen here.
}, 3600*24*365)
console.log('Cat', 'Dog', 'Bird')
console.log('Whatever, this app is immortal.')
That’s actually not true. Your website address needs to be pinged every 5 minutes. My program would always be doing something but it cannot stay alive.
Well, would you please explain to me why I have a discord bot, that does not host any http nor https servers, nor does it makes any http (or https) requests to any platform except Discord.
Anyways, if you guys have this issue, that a http server must be hosted, this just might be the very shortest fix.
Using setInterval() to keep a bot awake isn’t recommended as it will not be restarted if we have to stop projects. Providing an end-point to ping is a better approach.
i found https://cron-job.org/en/ works well. You make an account and make a new cron job. You set the adress as (projectname).glitch.me . you set the shedule to every 5 min (or less) and create cronjob (https://gyazo.com/2fb8f181517822cae4619cab82b58e1d) You don’t need an html file on your project