为什么 Heroku 每天重置我的文件 "data.json"?
Why Heroky reset my file "data.json" everyday?
我制作了一个将数据保存在文件中的 discordJs 机器人。
一切都托管在 Heroku 上并且一切正常。
但是每天,Heroku 都会重置我的文件。
为什么我不能每天保存我的文件?
这是来自 Heroku 文档的完整解释:
The Heroku filesystem is ephemeral - that means that any changes to
the filesystem whilst the dyno is running only last until that dyno is
shut down or restarted. Each dyno boots with a clean copy of the
filesystem from the most recent deploy. This is similar to how many
container based systems, such as Docker, operate.
In addition, under normal operations dynos will restart every day in a
process known as "Cycling".
These two facts mean that the filesystem on Heroku is not suitable for
persistent storage of data. In cases where you need to store data we
recommend using a database addon such as Postgres (for data) or a
dedicated file storage service such as AWS S3 (for static files). If
you don't want to set up an account with AWS to create an S3 bucket we
also have addons here that handle storage and processing of static
assets https://elements.heroku.com/addons
来源:https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted
我制作了一个将数据保存在文件中的 discordJs 机器人。 一切都托管在 Heroku 上并且一切正常。 但是每天,Heroku 都会重置我的文件。
为什么我不能每天保存我的文件?
这是来自 Heroku 文档的完整解释:
The Heroku filesystem is ephemeral - that means that any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted. Each dyno boots with a clean copy of the filesystem from the most recent deploy. This is similar to how many container based systems, such as Docker, operate.
In addition, under normal operations dynos will restart every day in a process known as "Cycling".
These two facts mean that the filesystem on Heroku is not suitable for persistent storage of data. In cases where you need to store data we recommend using a database addon such as Postgres (for data) or a dedicated file storage service such as AWS S3 (for static files). If you don't want to set up an account with AWS to create an S3 bucket we also have addons here that handle storage and processing of static assets https://elements.heroku.com/addons
来源:https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted