12 hours shutdown - way to do it manually?

Hi,

is there a way to do that 12 hours shutdown thing in specified time? My bot is doing some things every 15 minutes (hh:00, hh:15, hh:30 and hh:45). Because glitch and discord are not 100 reliable I have created a logic, that saves if this job was done, if not, it run it again. But the problem is, and that happened yesterday, that my bot was shunted down in the middle of the thing it should do, so it did not finish it in all guilds… Then after restart, it did it again (because it was not finished due to the glitch shut it down). So approximately half of guilds (about 150] were messed. The only thing I need is, not to shut down my bot at hh:00, hh:15, hh:30 and hh:45, is that possible?

Thanks for info

1 Like

This seems a bit ridiculous but you could create a program to essentially spam your project with >4000 requests every 15 minutes. I don’t recommend doing this however because I doubt DDoSing is allowed on Glitch.

Try using this code to do the 15min logic

option 1.

setTimeout(FUNCTION-NAME, 900000)

option 2.
Do an else if for the time like so

I think I messed this part up

if (Date.prototype.getMinutes() === 15) {
// code to run
} 

thanks, but that I think does not help the problem, when my project is shut down in the middle of my function, right? This just run the function every 15 minutes

Maybe try pinging your project domain every couple of minutes. Using Awake! or UptimeRobot

More info on tech restrictions: https://glitch.com/help/restrictions/
If you don’t mind paying for a paid plan go here: https://glitch.com/pricing (nvr goes to sleep/stop, etc)

that’s not my problem. Pinging is ok I do it. This part is a problem:
“and those running for more than 12 hours are stopped.”. The problem is not that it is stopped (I ping it and it starts again), but the problem is it is stopped in the wrong time. So the question is if there is a way to schedule “the stop” manually, so I can avoid stoping my project in the time it can make a mess?

i thought pinging every 5min would do the trick since it would have to wake up on request

edit: now i get the question and it wouldn’t be possible

if you ping the project every 5 minutes then you just keep it awake (help to this rule “Projects sleep after 5 minutes if they are not used”, but it will be forced to shutdown, I think killed by some cron job on the server every 12 hours ±

maybe‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

To prevent sleep after 5 minutes if they are not used, you can ping your project internally by your project itself (I guess pinging it every 4 minutes).

However your project will be forced to shutdown when your project is running up to 12 hours. You cant avoid this but to wake up your project or to starts your project after this shutdown, you need pinging your project externally (ex: uptime robot or some other cron) to wake it up again.

By using uptimerobot, at least your project is down up to 5 minutes for every 12 hours its up for running.

Sounds like you’ve got a process running that takes more than a minute or so, and you don’t want it the project to shut down in the middle of that process running.

One way people get around this is using a queue. When your project has a new “job” to execute, it could write that to a file on the disc (maybe adds it to a queue.json file and saves that).

Then, the project starts executing that, and removes it from queue.json when it’s done. If the project gets shut down in the middle or restarts, the job is still in queue.json, since it didn’t get finished.

Then, you tell your project to start where it left off and keep processing jobs from queue.json, and removing them when it’s finished.

Thank man, that make sense.) actually I am pushing some data to mysql db. Right now I just save the date when it finished the last run. Maybe I will have to save it for every guild (loop) and not for all at once.)