fjc0k / docker-YApi

接口管理平台 YApi 的 Docker 镜像。
https://hub.docker.com/r/jayfong/yapi/tags
MIT License
1.1k stars 262 forks source link

🎈被迫安装 user-add 插件引发的问题与思考! #20

Closed XiaoZiShan closed 4 years ago

XiaoZiShan commented 4 years ago

您的 docker-compose 项目做的非常不错 ! 我在安装中遇到一点小问题, 并提交了相关的 PR,

17 问题如何发生:

我 在 yapi 项目 readme 中发现了这个项目. 我使用了最新的 node 以及 docker 来 运行这个项目, 将项目 clone 到本地, 修改了按您的readme中的提示, 修改的用户名以及密码, 将项目启动, 登录使用都没有异常, 但发现了一个问题就是, yapi 无法注册用户, 看了日志并没有错误. 我看见了 插件列表中的 user-add 插件可以解决这个问题. 我安装了那个插件. 但是发现了下面的错误. 貌似关于 init.lock. 以我的 nodejs 水平, 暂时无法解决这个问题, 也可能是我操作的问题, 可以一起来完善下插件相关的文档, 我选择了修改 YAPI_CLOSE_REGISTER 为 false 后重新安装容器后可以注册用户.

🍰 yapi-web 日志

yapi-web      | 启动引导服务...
yapi-web      | 写入配置...
yapi-web      | {
yapi-web      |   "adminAccount": "xxxx@qq.com",
yapi-web      |   "db": {
yapi-web      |     "servername": "yapi-mongo",
yapi-web      |     "port": 27017,
yapi-web      |     "DATABASE": "yapi"
yapi-web      |   },
yapi-web      |   "mail": {
yapi-web      |     "enable": false,
yapi-web      |     "auth": {}
yapi-web      |   },
yapi-web      |   "ldapLogin": {
yapi-web      |     "enable": false
yapi-web      |   },
yapi-web      |   "closeRegister": false,
yapi-web      |   "plugins": {
yapi-web      |     "name": "add-user"
yapi-web      |   },
yapi-web      |   "adminPassword": "Password",
yapi-web      |   "port": 3000
yapi-web      | }
yapi-web      | 等待 MongoDB 服务可用...
yapi-web      | 安装 YApi 插件...
yapi-web      | 尝试安装 YApi...
yapi-web      | + node '--unhandled-rejections=strict' ./vendors/server/install.js
yapi-web      | 
yapi-web      | (node:17) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
yapi-web      | 
yapi-web      | log: mongodb load success...
yapi-web      | 
yapi-web      | 初始化管理员账号成功,账号名:"xxx@qq.com",密码:"Password"
yapi-web      | 
yapi-web      | 关闭引导服务...
yapi-web      | 尝试启动 YApi...
yapi-web      | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Error: 插件配置有误,请检查
yapi-web      |     at exports.initPlugins (/yapi/vendors/common/plugin.js:30:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/plugin.js:235:21)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/app.js:10:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Main.start (/yapi/start.js:340:9)
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
yapi-web      | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
yapi-web      | log: mongodb load success...
yapi-web      | 启动引导服务...
yapi-web      | 写入配置...
yapi-web      | {
yapi-web      |   "adminAccount": "xxxx@qq.com",
yapi-web      |   "db": {
yapi-web      |     "servername": "yapi-mongo",
yapi-web      |     "port": 27017,
yapi-web      |     "DATABASE": "yapi"
yapi-web      |   },
yapi-web      |   "mail": {
yapi-web      |     "enable": false,
yapi-web      |     "auth": {}
yapi-web      |   },
yapi-web      |   "ldapLogin": {
yapi-web      |     "enable": false
yapi-web      |   },
yapi-web      |   "closeRegister": false,
yapi-web      |   "plugins": {
yapi-web      |     "name": "add-user"
yapi-web      |   },
yapi-web      |   "adminPassword": "Password",
yapi-web      |   "port": 3000
yapi-web      | }
yapi-web      | 等待 MongoDB 服务可用...
yapi-web      | 安装 YApi 插件...
yapi-web      | 尝试安装 YApi...
yapi-web      | + node '--unhandled-rejections=strict' ./vendors/server/install.js
yapi-web      | 
yapi-web      | /yapi/vendors/server/install.js:15
yapi-web      |     throw new Error(
yapi-web      |     ^
yapi-web      | 
yapi-web      | Error: init.lock文件已存在,请确认您是否已安装。如果需要重新安装,请删掉init.lock文件
yapi-web      |     at install (/yapi/vendors/server/install.js:15:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/install.js:155:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
yapi-web      |     at internal/main/run_main_module.js:17:47
yapi-web      | 
yapi-web      | 关闭引导服务...
yapi-web      | 尝试启动 YApi...
yapi-web      | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Error: 插件配置有误,请检查
yapi-web      |     at exports.initPlugins (/yapi/vendors/common/plugin.js:30:11)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/plugin.js:235:21)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Object.<anonymous> (/yapi/vendors/server/app.js:10:1)
yapi-web      |     at Module._compile (internal/modules/cjs/loader.js:1147:30)
yapi-web      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
yapi-web      |     at Module.load (internal/modules/cjs/loader.js:996:32)
yapi-web      |     at Function.Module._load (internal/modules/cjs/loader.js:896:14)
yapi-web      |     at Module.require (internal/modules/cjs/loader.js:1036:19)
yapi-web      |     at require (internal/modules/cjs/helpers.js:72:18)
yapi-web      |     at Main.start (/yapi/start.js:340:9)
yapi-web      | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
yapi-web      | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

补救方式:

建议将 YAPI_CLOSE_REGISTER 默认设置为 false , 可以在第一次运行时就不会出现这样的连环问题.

XiaoZiShan commented 4 years ago

我并不需要 user-add 插件, 我只想正常的使用 yapi

XiaoZiShan commented 4 years ago

我在调试的过程中安装了很多次容器.

fjc0k commented 4 years ago

配置文档很详细,你应该先看看的:https://github.com/fjc0k/docker-YApi#%E9%80%9A%E8%BF%87%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE

而且你插件配置也有问题,错误提示已经很清楚了,正确的应该是数组: image

如果你仔细看了文档,是不会出现你所说的问题的,因此,作为一个我比较推荐的默认选项:关闭注册,目前不考虑变更,谢谢。

XiaoZiShan commented 4 years ago

好的

XiaoZiShan commented 4 years ago

配置文档很详细,你应该先看看的:https://github.com/fjc0k/docker-YApi#%E9%80%9A%E8%BF%87%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE

而且你插件配置也有问题,错误提示已经很清楚了,正确的应该是数组: image

如果你仔细看了文档,是不会出现你所说的问题的,因此,作为一个我比较推荐的默认选项:关闭注册,目前不考虑变更,谢谢。

是的, 确实是我的问题 , 建议把 user-add 插件内置到 docker-compose.yml 的插件选项里, 这样就可以减少小白用户不必要的 issue

fjc0k commented 4 years ago

加上插件会导致安装耗时较多,而且设备不好的话,还可能安装失败,因此没有内置。