alist
alist copied to clipboard
多个alist服务共用一个mysql数据库
Please make sure of the following things
- [X] I have read the documentation.
- [X] I'm sure there are no duplicate issues or discussions.
- [X] I'm sure this feature is not implemented.
- [X] I'm sure it's a reasonable and popular requirement.
Description of the feature / 需求描述
标题可能不够准确,现在是可以共用一个mysql数据库,但是有些场景使用有些问题。比如,多个服务(A,B,C)同时都挂载了本地盘,在访问B服务时,仍然会展示A,C的挂载目录,其实是无法访问的。还有后续如果要实现自动备份,也是要区分具体是哪个服务器的。
Suggested solution / 实现思路
功能我这边已经实现了,思路如下
- config.json里面增加一个server_id字段用于标识服务器id,自己配置就可以
- 代码里面Config结构体增加对应的字段
- 数据表x_storages增加server_id字段(这个字段只对驱动类型为Local的存储有意义)
- 编辑驱动类型为Local的存储时,自动添加当前服务id到数据表
- 获取存储时,过滤掉驱动为Local且server_id与配置的server_id不一致的存储
这个方案可以扩展,此后如果有需要用到需要区分服务器的场景,都可以使用server_id字段来区分具体的服务器。
Additional context / 附件
修改前
修改后