Strapi 数据库在 Render 服务器宕机时清空

huangapple go评论50阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年3月31日 18:43:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897617.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定