cokemine / nodestatus

Yet another servers monitor written in TypeScript
https://nodestatus-production.up.railway.app
MIT License
342 stars 65 forks source link

关于数据库 #193

Closed DesnLee closed 1 year ago

DesnLee commented 1 year ago

有两个问题:

  1. 使用 pnpm 安装全局包运行, 配置 dotenv 中的数据库 connection string 的变量名应该为 DATABASE_URL, README 中并没有提到;
  2. 我使用远程 PostgreSQL 作为数据库,实际程序并没有使用该数据库,仍然使用了本地 SQLite,请问这个是什么原因呢?
cokemine commented 1 year ago

环境变量名应该是 DATABASE 不是 DATABASE_URL。这是个历史遗留问题会处理成 Prisma的环境变量 DATABASE_URL 改成 DATABASE 也不行吗

DesnLee commented 1 year ago

环境变量名应该是 DATABASE 不是 DATABASE_URL。这是个历史遗留问题会处理成 Prisma的环境变量 DATABASE_URL 改成 DATABASE 也不行吗

使用 DATABASE,admin 面板 management 会报 500 the URL must start with the protocol 'file:', 我看 prisma schema 里面的 db provider 是写死的 sqlite,url 就必须以 file: 开头了

DesnLee commented 1 year ago

https://github.com/cokemine/nodestatus/blob/04e62ebde75b7878a0bbb00a2b69ab8e0f81d48f/packages/nodestatus-server/server/model/server.ts#L29 这一行报错了

cokemine commented 1 year ago

我在 prestart 和 postinstall 里做了个 init 脚本去修改了这个 db provider。直接 status-server-run 不会触发这个钩子。

定义 dotenv 文件之后再 npm i nodestatus-server@latest --unsafe-perm -g 应该会执行 init 脚本,应该是个暂时的解决办法

DesnLee commented 1 year ago

我在 prestart 和 postinstall 里做了个 init 脚本去修改了这个 db provider。直接 status-server-run 不会触发这个钩子。

定义 dotenv 文件之后再 npm i nodestatus-server@latest --unsafe-perm -g 应该会执行 init 脚本,应该是个暂时的解决办法

可以了。之前是先跑起来才创建的 dotenv,重新装了一下,把 sqlite 数据迁移了一下,ok了。

cokemine commented 1 year ago

最新版应该修复这个问题了

DesnLee commented 1 year ago

最新版应该修复这个问题了

ok ,我已经用上面的方法迁移完了。选择这样是因为docker好像没提供arm镜像