rokevin
移动
前端
语言
  • 基础

    • Linux
    • 实施
    • 版本构建
  • 应用

    • WEB服务器
    • 数据库
  • 资讯

    • 工具
    • 部署
开放平台
产品设计
  • 人工智能
  • 云计算
计算机
其它
GitHub
移动
前端
语言
  • 基础

    • Linux
    • 实施
    • 版本构建
  • 应用

    • WEB服务器
    • 数据库
  • 资讯

    • 工具
    • 部署
开放平台
产品设计
  • 人工智能
  • 云计算
计算机
其它
GitHub
  • YAPI

YAPI

项目地址

https://hellosean1025.github.io/yapi/

https://hellosean1025.github.io/yapi/

https://hellosean1025.github.io/yapi/index.html

环境要求

  • nodejs(7.6+)
  • mongodb(2.6+) 查看安装
  • git

安装

使用我们提供的 yapi-cli 工具,部署 YApi 平台是非常容易的。执行 yapi server 启动可视化部署程序,输入相应的配置和点击开始部署,就能完成整个网站的部署。部署完成之后,可按照提示信息,执行 node/{网站路径/server/app.js} 启动服务器。在浏览器打开指定url, 点击登录输入您刚才设置的管理员邮箱,默认密码为 ymfe.org 登录系统(默认密码可在个人中心修改)。

npm install -g yapi-cli --registry https://registry.npm.taobao.org
yapi server 

启动服务后在输入 ip:9090访问安装页面,根据提示输入对应信息

配置mongodb信息,点击下一步安装

安装完成后访问 ip:配置的网页端口号 账户是管理员邮箱 密码是ymfe.org

服务管理

利用pm2方便服务管理维护。

npm install pm2 -g  //安装pm2
cd  {项目目录}
pm2 start "vendors/server/app.js" --name yapi //pm2管理yapi服务
pm2 info yapi //查看服务信息
pm2 stop yapi //停止服务
pm2 restart yapi //重启服务

升级

升级项目版本是非常容易的,并且不会影响已有的项目数据,只会同步 vendors 目录下的源码文件。

cd  {项目目录}
yapi ls //查看版本号列表
yapi update //更新到最新版本
yapi update -v {Version} //更新到指定版本

PM2设置开机自启动

  • 运行 pm2 startup,即在/etc/init.d/目录下生成pm2-root的启动脚本,且自动将pm2-root设为服务。

  • 运行 pm2 save,会将当前pm2所运行的应用保存在/root/.pm2/dump.pm2下,当开机重启时,运行pm2-root服务脚本,并且到/root/.pm2/dump.pm2下读取应用并启动。

批量增加用户

admin.user.json

{ 
    "_id" : NumberInt(11), 
    "study" : true, 
    "type" : "site", 
    "username" : "管理员用户", 
    "email" : "test1@rokevin.cn", 
    "password" : "631eac1d818e4640c7dc845be7c15ead5dd65007", 
    "passsalt" : "roulqwr62a", 
    "role" : "admin", 
    "add_time" : NumberInt(1573055202), 
    "up_time" : NumberInt(1573055520), 
    "__v" : NumberInt(0)
}
{ 
    "_id" : NumberInt(21), 
    "study" : false, 
    "type" : "site", 
    "username" : "普通用户密码111111", 
    "password" : "631eac1d818e4640c7dc845be7c15ead5dd65007", 
    "email" : "test2@qq.com", 
    "passsalt" : "6g4ek8jyxi", 
    "role" : "member", 
    "add_time" : NumberInt(1573119875), 
    "up_time" : NumberInt(1573119875), 
    "__v" : NumberInt(0)
}

网站端口注意填写,要不然一直提示正在安装

遇到的问题

问题1:初始化数据库报错

Error: (node:90198) 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.

修改文件 vendors/server/utils/db.js 在原来的

let options = {useNewUrlParser: true, useCreateIndex: true}

添加useUnifiedTopology: true选项改成

let options = {useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true}

删除mongo里面的数据库,和init.lock文件,

然后在vendors里执行npm run install-server

问题2:初始化管理员账号失败

解决方法:删除mongodb数据库中已创建的管理员数据,重新运行

错误处理

https://www.cnblogs.com/superhin/p/12340560.html

教程

https://www.runoob.com/mongodb

最近更新:: 2020/7/26 21:46
Contributors: luokaiwen