Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可视化部署时,初始化数据库mongodb失败 #1605

Closed
chen-viky opened this issue Feb 6, 2020 · 4 comments
Closed

可视化部署时,初始化数据库mongodb失败 #1605

chen-viky opened this issue Feb 6, 2020 · 4 comments

Comments

@chen-viky
Copy link

版本号

~

  • node : v10.16.3
  • mongodb: v4.2.3

什么问题

~

可视化部署时,初始化数据库mongodb失败

yapi-vendor@1.8.7 install-server /root/yapi/vendors > node server/install.js
Error: (node:27668) 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-cli 可视化部署

什么浏览器

~

什么系统(Linux, Windows, macOS)

centos7

@yeongjet
Copy link

yeongjet commented Feb 7, 2020

#1607

@chen-viky
Copy link
Author

使用命令行模式,修改 vendors/server/utils/db.js 内,mongosse连接参数

原代码:let options = {useNewUrlParser: true, useCreateIndex: true};
修改为: let options = {useNewUrlParser: true, useCreateIndex: true,useUnifiedTopology: true };
然后执行安装服务即可。

@chen-viky
Copy link
Author

我用notepad++打开后修改源码不起作用,必须用命令行模式修改么?

是的,使用可视化部署,会重新clone一份yapi项目,覆盖你修改的内容。
如果觉得命名行模式clone比较慢,可以使用码云 https://gitee.com/mirrors/YApi

步骤如下

mkdir yapi
cd yapi
git clone https://gitee.com/mirrors/YApi.git vendors //或者下载 zip 包解压到 vendors 目录(clone 整个仓库大概 140+ M,可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M)
cp vendors/config_example.json ./config.json //复制完成后请修改相关配置
cd vendors
/**
* 修改 vendors/server/utils/db.js 内,mongosse连接参数
* 原代码:let options = {useNewUrlParser: true, useCreateIndex: true};
* 修改为: let options = {useNewUrlParser: true, useCreateIndex: true,useUnifiedTopology: true };
*/
npm install --production --registry https://registry.npm.taobao.org
npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置
node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候

@sky-ky
Copy link

sky-ky commented Feb 21, 2020

我用记事本++打开后修改源码不起作用,必须用命令行模式修改么?

是的,使用可视化部署,会重新克隆一份yapi项目,覆盖你修改的内容.如果觉得命名行模式克隆比较慢,可以使用码云https://gitee.com/mirrors/YApi

步骤如下

mkdir yapi
cd yapi
git clone https://gitee.com/mirrors/YApi.git vendors //或者下载 zip 包解压到 vendors 目录(clone 整个仓库大概 140+ M,可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M)
cp vendors/config_example.json ./config.json //复制完成后请修改相关配置
cd vendors
/**
* 修改 vendors/server/utils/db.js 内,mongosse连接参数
* 原代码:let options = {useNewUrlParser: true, useCreateIndex: true};
* 修改为: let options = {useNewUrlParser: true, useCreateIndex: true,useUnifiedTopology: true };
*/
npm install --production --registry https://registry.npm.taobao.org
npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置
node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候

十分感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants