Do runtime changes to Python variables and files in Heroku apps update the original GitHub repository?

I built a Python chatbot for Twitch and deployed it on Heroku through GitHub integration. My bot has features where viewers can use chat commands to modify data. There’s a counting feature that increases a number variable each time someone uses a particular command. I also have another command that lets users append text to a .txt file.

I’m wondering about how these runtime modifications work. When users interact with my bot and change the counter value or add entries to the text file, do these changes get saved back to my GitHub repository? Or do they only exist within the Heroku application environment?

I tested both commands and noticed that the modifications don’t appear in my GitHub code when I check it later. The counter stays at its original value and the text file remains unchanged in the repo. Is there a method to sync these runtime changes back to GitHub automatically?

Indeed, the behavior you’re experiencing is standard for Heroku. Its filesystem is temporary, meaning any runtime changes will be lost once the dyno restarts. Your GitHub repository remains unaffected, as it operates independently from the running application.

I encountered this issue with a Discord bot that tracked user statistics. Everything was functioning perfectly until, after an automatic restart by Heroku, all the data vanished.

To achieve persistent storage, consider implementing a database such as PostgreSQL or utilizing an external storage service. For your counter, you could create a simple table. For appending data, either a database text field or services like AWS S3 are suitable options. This separation of concerns is beneficial, as it ensures your source code remains intact.

Indeed, the changes you’re making only exist in the Heroku dyno and do not affect your GitHub repository, which is ideal since GitHub is designated for source code rather than transient runtime data. I experienced similar issues when deploying a web application that stored results temporarily – these were lost upon the next deployment due to Heroku’s ephemeral filesystem. This means that any changes you make during runtime are wiped when the dyno restarts, which occurs regularly. To maintain the counter and your text data persistently, consider using Heroku’s free PostgreSQL add-on for the counter as it’s straightforward for numerical values. For managing text entries, you might think about storing them as database records or utilizing services like Google Drive API if file preservation is essential.

exactly, heroku dynos clear up on restart, so any runtime changes vanish. your github repo stays untouched, which is good since runtime stuff shouldn’t mix with code. for the counter, postgresql is the way to go, and if you need quick storage, redis can work wonders.

No, runtime changes do not sync back to GitHub. Heroku’s filesystem is temporary, meaning that any modifications made during runtime will be lost when your dyno restarts, which occurs regularly. This explains why both your counter and text file revert to their initial states. I learned this the hard way on my first deployment and lost critical user data. For persistent storage, consider using external services such as PostgreSQL for structured data or AWS S3 for file storage. Heroku offers free PostgreSQL add-ons, which are suitable for managing counters and other variable data. Reserve your GitHub repository for source code exclusively and not for runtime data that fluctuates frequently.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.