Forums

Always on task - 'task preparing to start' and nothing happens

Hi, i'm traying to peploy an Flask and MySQL app with Always On tasks but it just says "starting" and "Task preparing to start" at action button. When I 'reload' my app in 'Web' tab, its working without problem but it stops after a few seconds. How can I make my app remains opperative all time? Thanks ind advance for your help.

The always-on task stops after a few seconds? I recommend adding some more logging to figure out where it's failing. Check out this help page: https://help.pythonanywhere.com/pages/AlwaysOnTasks#stuff-that-you-print-doesnt-appear-in-the-log

No, Always on task doesn't stops, it never starts. What I'm saying is, when I 'reload' my app in the 'Web' tab, it works, but just for a few seconds. Then it just send me to a page with the message: 'Internal Server Error'. If I reload it again, it works again. But with Always On tasks, it doesent works at all, it just says 'Starting'...

I checked out your always-on task, and it looks like it's trying to run a Flask app. You don't need to do that in order to run a website; when a website is configured on the "Web" page, it's started up right away, and if it's ever shut down, it will be started up again as soon as a request comes in. If you try to configure one as an always-on task, then a normally-configured Flask app will just start, exit, start again, exit again, and so on -- so on the "Tasks" page it will always look like it's starting, and the logs will just contain "Task preparing to start" because it will never log anything. So I recommend you just delete that always-on task, it's not doing anything useful.

Regarding internal server errors on your website -- check out the website's error log for that. There's a link to that on the "Web" page, and the most recent error will be at the bottom of the file.

Thanks for your answer. I checked the server errors and it says: "mysql.connector.errors.OperationalError: 2013 (HY000): Lost connection to MySQL server during query". How can I maintain my MySQL connection stable?

We have a help page about managing database connections.