Error trying to develop Flask Server

Question: Error trying to develop Flask Server, and that the server just stops and not keep on running after 6 hours:

Repl link/Link to where the bug appears:
https://replit.com/@YoungBuck9696/Ultimate-News-Scrapper

Screenshots, links, or other helpful context:

code snippet
2 Likes

Hi @YoungBuck9696 , welcome to the forums!
To keep your server running, you need to deploy your repl as an Autoscale Deployment.
Hope this helps!

2 Likes

I have already deployed the project as Autoscale Deployment. The flask server is on, but somehow the Python code inside just stops. When I was in Always On mode, the Python code never stopped. Can you give me suggestions on why things may happen? @NateDhaliwal

Hi @YoungBuck9696 !
The run button is for development, to test things out.
Your Flask server will be turned on when there is an incoming request, and is off when there isn’t one to save resources.
Hope this helps!

1 Like

Thank you, I will try again and fingers crossed.

so @NateDhaliwal I believe that even though I have deployed my code, I still could not make my Python code run every 6 hours, the code runs one time and stops entirely. I am not sure why.

2 things:

  1. Do not have your serviceAccountKey stored there: it’s very unsafe as anyone can see it. Store it with Secrets.
  2. I see, your repl is a bot but is using Flask. What type of Reserved VM are you using? Web Server?

Reserved VMs turn the repl on 99.9% of the time, not every once in a while. Autoscale turn the repl on when there is an incoming request. There isn’t an actual way to control when the repl runs.

3 Likes

Looks like you only waited 25 minutes, not the 6 hours, though?

1 Like

I just opened my Replit again and the code is still not running. I thought that it should keep on running as I have requested.

Even if the run button shows it is not running, your deployment is still running. The run button is separate from your deployment.

If your website turns off, then there is a problem.

Can you confirm this is what’s happening?

1 Like

Thank you for your response. It looks to me that the website is still running, but the Python code itself stops after one round. In my design the code should run every 3 hours. So in short, the Flask website is still on, and the code is deployed, but the Python code inside itself does not keep repeating every set of hours.

@YoungBuck9696 Autoscale deployments don’t work like that, they only run when they receive a request.

2 Likes

Yes. To add on, @YoungBuck9696 should deploy as Reserved VM if they want it to be on 24/7.

2 Likes