英文:
Strapi database empties if Render server goes down
问题
我在Render上部署了一个Strapi后端。直到昨天,Render服务器短暂宕机之前,一切都运行正常。看起来这不应该是个大问题,因为服务器恢复运行后,Strapi也重新激活了。
问题是,这之后数据库中的所有数据都丢失了,并且分配的公共角色也被停用了。也就是说,Strapi处于与初始创建项目后部署时相同的状态。
有人知道如何在其他情况下预防这种情况吗?
谢谢!
英文:
I have a Strapi backend deployed on Render. I had no issue until yesterday, when the Render server went down for a few minutes. It looks like it shouldn't be a big problem because when the server started working again Strapi was also reactivated.
The thing is, that all the database was empty after this and the asigned public roles were deactivated. That is to say, Strapi was in the same situation as if it was deployed right after creating the project at the beginning.
Does anyone know how to prevent this in some other occasions?
Thanks!
答案1
得分: 0
是因为 Strapi 默认在 config/database.ts
(或 .js)中有类似以下的内容:
filename: path.join(
__dirname,
'../..',
'../..',
env('DATABASE_FILENAME', '.tmp/data.db')
),
这意味着数据库文件名位于克隆并清理的存储库内。你需要修改配置,类似于 https://github.com/render-examples/strapi-sqlite/blob/master/config/database.js。
英文:
It is because Strapi has - by default - in config/database.ts
(or .js) something like:
filename: path.join(
__dirname,
'..',
'..',
env('DATABASE_FILENAME', '.tmp/data.db')
),
That means database filename is inside your repo that is cloned and cleaned up. You have to modify your config similarly to https://github.com/render-examples/strapi-sqlite/blob/master/config/database.js.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论