问题
I have an app deployed on Heroku that reads a line from a file, then is supposed to delete that line in the file and add that line to a different file. If all the necessary files are in the Heroku git repo and assuming the code runs without any errors, will the files be changed?
回答1:
Changes made directly to the filesystem on Heroku dynos will be lost whenever your dyno restarts. This happens frequently:
Dynos are also restarted (cycled) at least once per day to help maintain the health of applications running on Heroku. Any changes to the local filesystem will be deleted. The cycling happens once every 24 hours (plus up to 216 random minutes, to prevent every dyno for an application from restarting at the same time).
Instead of writing to a file on the filesystem you should consider using a database. Heroku provides a PostgreSQL service, but there are many other options.
If for some reason you really do need to store a file, Heroku recommends using something like Amazon S3.
来源:https://stackoverflow.com/questions/42194043/can-heroku-edit-files