Can Heroku edit files?

淺唱寂寞╮ 提交于 2021-01-15 11:24:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!