thx / rap2-delos

阿里妈妈前端团队出品的开源接口管理工具RAP第二代
http://rap2.taobao.org
MIT License
7.65k stars 1.35k forks source link

非官方rap2-delos部署文档 #119

Closed BladeCode closed 6 years ago

BladeCode commented 6 years ago

前言

RAP2 包含两个组件 客户端:rap2-dolores服务端:rap2-delos
部署RAP2需要亲具有Node+Linux+MySQL的运维知识,如果亲对此不是很了解,建议用http://rap2.taobao.org 线上版本就可以了。

构建项目

安装基本工具

以上基本工具请根据自身需要,下载对应系统安装包,请自行解决安装配置等问题,这里不做过多说明

获取源代码

git clone https://github.com/thx/rap2-delos.git

导入VS Code

这里的开发编辑工具推荐,当然你也可以用自己熟悉的开发工具

环境配置

创建数据库

配置文件

目录:rap2-delos/src/config
文件:config.dev.ts;其中dev,表示开发环境,其他同理
修改:config.dev.ts文件中db对象中usernamepassword参数与本地或者开发环境的数据库信息匹配

启动项目

安装项目依赖包

项目根目录下执行

npm install

如果下载缓慢,请使用淘宝npm镜像

初始化数据库

项目根目录下执行

npm run create-db

编译启动项目

执行mocha测试用例和js代码规范检查

npm run check

看到浏览器中如下提示,表示服务端delos已经部署成功

RAP2后端服务已启动,请从前端服务(rap2-dolores)访问。 RAP2 back-end server is started, please visit via front-end service (rap2-dolores).

常见问题

部署问题

  1. Windows下执行npm run build,提示'rm' 不是内部或外部命令,也不是可运行的程序或批处理文件

    原因:rm 是Linux下命令,
    解决方法:Windows系统可使用 git bash 打开该项目,执行该命令

  2. 执行npm run create-db命令,提示Unable to connect to the database:{ SequelizeAccessDeniedError: Access denied for user 'root'@'localhost' (using password:NO)}

    原因:未修改rap2-delos/src/config目录下数据库配置文件,或者是与文件中的数据库信息与之连接的数据库信息不匹配 解决方法:修改config.dev.ts文件数据库配置信息

    如果修改正确无误后,执行npm run create-db依旧出错,那么查看该项目中是否已经存在dist目录,如果有,请按照如上修改对应的数据库配置信息

如何获取更新

目前请选择master分支源码,后续其他分支请看相应分支说明文档。在开发环境中git pull来获取最新的源码更新,每一期更新都会有对应的update.md请关注并按照上面的指示进行升级工作。

更详细的安装部署请移步:https://incoder.org/2018/03/27/rap2/

jeff-fe commented 6 years ago

@BladeCode 你好,这代码中没有dist/目录文件,项目无法运行!请问您是怎么处理的?

lsw2013 commented 6 years ago

@jeffhuang2086 看看package.json,运行 npm run build 就可以启动 ts 编译,把源文件编译到 dist 文件夹里面,就有 dist/ 目录了。

WeekiXu commented 6 years ago

咨询下,版本升级中怎么应对数据库的部分?需要每个表比对吗?

Bosn commented 6 years ago

赞👍

Bosn commented 6 years ago

@WeekiXu 版本升级,一般在Database/文件夹下有不同版本的数据库改动SQL脚本。

v2.5之后的我都放这里了,v2.5之前不是我写的.... 不过我方出来公开到github上就已经2.5了

lijiangwei commented 6 years ago

静态资源使用nginx部署的,接口请求如何代理到后台服务?

njleonzhang commented 6 years ago

@Bosn 有docker部署方案么

silencenight commented 6 years ago

centos部署,浏览器中访问端口提示:RAP2后端服务已启动,请从前端服务(rap2-dolores)访问。 RAP2 back-end server is started, please visit via front-end service (rap2-dolores). 接下来还要部署前端项目吗?要是部署的话,在什么地方下载啊?

njleonzhang commented 6 years ago

@silencenight 老哥文档里有啊。https://github.com/thx/rap2-dolores 你问这个问题,维护的人真是要忙死。

Bosn commented 6 years ago

已Link至README.md 感谢热心开源同胞

https://github.com/thx/rap2-delos/commit/87b7d0d2ac9fde97d261003300723c7f62210224

wangfengcool commented 6 years ago

开始部署了。

freecatBy commented 6 years ago

@Bosn 数据库表( Table 'RAP2_DELOS_APP.Users' doesn't exist)好像跟1也有点出入,如果正式开源是否也可以方便提供

chofoo commented 6 years ago

文档写的没有官方的详细,有坑

kkroy-zs commented 6 years ago

npm install之后要先执行npm run build,否则没有dist目录

wsg9894 commented 6 years ago

今天捣鼓了很久,终于部署完毕

lanmingle commented 6 years ago

整了一个混合的Docker版本,基本上满足使用,可以在这里查看.

jackxueman commented 6 years ago

Request URL:http://ip:8080/account/register Request Method:POST Status Code:500 Internal Server Error Remote Address:ip:8080 Referrer Policy:no-referrer-when-downgrade

Haphets commented 6 years ago

rap2-dolores 客户端执行了npm run build以后,怎么代理呢?能不能发一份你的nginx配置文件。

myb858 commented 6 years ago

@Haphets server { listen 80; server_name rap2.xxxxxx.com; root /mnt/www/rap_api/rap2-dolores/build; location / { try_files $uri /index.html; } }

qifengwangye commented 6 years ago

请问此项目如何改变打包的路径?此前一直在使用webpack的项目,对非webpack项目打包不熟悉。我在package.json中添加homepage属性后只能修改当时引入的js,懒加载的js文件无法修改成功。请问如何解决?

caseyding commented 6 years ago

delos初始化数据库的时候,插入数据库的基础数据里面的中文都是乱码的,怎么解决呢?

lihuiby commented 6 years ago

windows下 npm start, 停止不了了, 怎么回事? 开了一堆node窗口, 任务管理器中结束进程树不行, 找到8080端口的pid, 结束进程还是不行, 是什么情况? 难道要重启机器?

lihuiby commented 6 years ago

redis使用了密码, 在npm run create-db的时候就报错了, 修改了配置文件 src/config/config.dev.ts 的redisOptions.password 选项, 还是报错, 好像还是权限问题, 有遇到的吗?

skylto commented 6 years ago

image 晕,注册的时候,为什么会有这样的提示,json字符串解析错误

XinuxC commented 6 years ago

image 晕,注册的时候,为什么会有这样的提示,json字符串解析错误

大哥 这个问题你解决了吗

glm1024 commented 6 years ago

解决了,配置文件的数据库没改,用的默认的,默认的那个不对,看了好几遍才找到原因,尴尬

XinuxC notifications@github.com 于2018年11月2日周五 下午2:28写道:

[image: image] https://user-images.githubusercontent.com/8804055/46863086-0b297180-ce49-11e8-904b-3ef1c38f258c.png 晕,注册的时候,为什么会有这样的提示,json字符串解析错误

大哥 这个问题你解决了吗

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thx/rap2-delos/issues/119#issuecomment-435284045, or mute the thread https://github.com/notifications/unsubscribe-auth/AS5bE6TSWxQtxUWGXKK525ASM0pGNsiHks5uq-YDgaJpZM4S8ctb .

partys88 commented 6 years ago

npm run create-db

rap2-delos@1.0.0 create-db /home/snt/rap2/rap2-delos cross-env NODE_ENV=development node dist/scripts/init

sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/sequelize/lib/sequelize.js:242:13 sequelize deprecated beforeDelete hook has been deprecated, please use beforeDestroy hook instead node_modules/sequelize/lib/hooks.js:160:13 Unable to connect to the database: { SequelizeConnectionError: connect ETIMEDOUT at Utils.Promise.tap.then.catch.err (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:149:19) From previous event: at ConnectionManager.connect (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:136:13) at sequelize.runHooks.then (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:320:50) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) From previous event: at ConnectionManager._connect (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:320:8) at ConnectionManager.getConnection (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:46) at Promise.try (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/sequelize.js:554:34) From previous event: at Promise.resolve.retryParameters (/home/snt/rap2/rap2-delos/node_modules/sequelize/lib/sequelize.js:454:64) at /home/snt/rap2/rap2-delos/node_modules/retry-as-promised/index.js:39:21

mynameismaosheng commented 5 years ago

解决了,配置文件的数据库没改,用的默认的,默认的那个不对,看了好几遍才找到原因,尴尬 XinuxC notifications@github.com 于2018年11月2日周五 下午2:28写道: [image: image] https://user-images.githubusercontent.com/8804055/46863086-0b297180-ce49-11e8-904b-3ef1c38f258c.png 晕,注册的时候,为什么会有这样的提示,json字符串解析错误 大哥 这个问题你解决了吗 — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#119 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AS5bE6TSWxQtxUWGXKK525ASM0pGNsiHks5uq-YDgaJpZM4S8ctb .

请问你改的是delos的dev配置吗? local配置需不需要改啊?

mynameismaosheng commented 5 years ago

请问下 delos bulid. prod的环境变量是在哪里设置的呢? 我想用process.env 但是没找到配置的地方啊

mynameismaosheng commented 5 years ago

redis使用了密码, 在npm run create-db的时候就报错了, 修改了配置文件 src/config/config.dev.ts 的redisOptions.password 选项, 还是报错, 好像还是权限问题, 有遇到的吗?

请问redis有密码怎么处理啊?解决了吗

15072314647 commented 5 years ago

@mynameismaosheng redis的密码问题需要修改对应的config.XXX.js redis: { host: process.env.REDIS_URL || 'localhost', port: (process.env.REDIS_PORT && parseInt(process.env.REDIS_PORT)) || 6379, auth_pass: process.env.REDIS_PWD --加上这个,然后环境变量配置redis的密码 }

abcadd commented 5 years ago

请问redis集群的配置怎么写?

15072314647 commented 5 years ago

[cid:image002.png@01D49791.194FCFA0]

[cid:image004.png@01D49791.18B0A970] 希望对你有帮助;

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: abcadd notifications@github.com 发送时间: Wednesday, December 19, 2018 11:39:29 AM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119)

请问redis集群的配置怎么写?

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/thx/rap2-delos/issues/119#issuecomment-448458907, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImFKlnCp8vO_AmD2Iy6qeDWf6jFcLks5u6bTxgaJpZM4S8ctb.

abcadd commented 5 years ago

[cid:image002.png@01D49791.194FCFA0] [cid:image004.png@01D49791.18B0A970] 希望对你有帮助; 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用 ____ 发件人: abcadd notifications@github.com 发送时间: Wednesday, December 19, 2018 11:39:29 AM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119) 请问redis集群的配置怎么写? ― You are receiving this because you commented. Reply to this email directly, view it on GitHub<#119 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImFKlnCp8vO_AmD2Iy6qeDWf6jFcLks5u6bTxgaJpZM4S8ctb.

没看见您回复的图片,请问需要修改哪些配置?谢谢

15072314647 commented 5 years ago

说明放到我的github上了 https://github.com/15072314647/rap2-delos/blob/master/redis.md

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: abcadd notifications@github.com 发送时间: Wednesday, December 19, 2018 3:26:02 PM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119)

[cid:image002.png@01D49791.194FCFA0] [cid:image004.png@01D49791.18B0A970] 希望对你有帮助; 发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用https://go.microsoft.com/fwlink/?LinkId=550986%3E%E5%BA%94%E7%94%A8____ 发件人: abcadd notifications@github.commailto:notifications@github.com 发送时间: Wednesday, December 19, 2018 11:39:29 AM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119https://github.com/thx/rap2-delos/issues/119) 请问redis集群的配置怎么写? D You are receiving this because you commented. Reply to this email directly, view it on GitHub<#119 (comment)https://github.com/thx/rap2-delos/issues/119#issuecomment-448458907>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImFKlnCp8vO_AmD2Iy6qeDWf6jFcLks5u6bTxgaJpZM4S8ctb.

没看见您回复的图片,请问需要修改哪些配置?谢谢

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/thx/rap2-delos/issues/119#issuecomment-448495522, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImMoj2W2Z88qcaLnZnVf28lUnsJ-Wks5u6eoKgaJpZM4S8ctb.

abcadd commented 5 years ago

说明放到我的github上了 https://github.com/15072314647/rap2-delos/blob/master/redis.md 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用 ____ 发件人: abcadd notifications@github.com 发送时间: Wednesday, December 19, 2018 3:26:02 PM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119) [cid:image002.png@01D49791.194FCFA0] [cid:image004.png@01D49791.18B0A970] 希望对你有帮助; 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用<https://go.microsoft.com/fwlink/?LinkId=550986%3E%E5%BA%94%E7%94%A8> … ____ 发件人: abcadd notifications@github.commailto:notifications@github.com 发送时间: Wednesday, December 19, 2018 11:39:29 AM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119<#119>) 请问redis集群的配置怎么写? D You are receiving this because you commented. Reply to this email directly, view it on GitHub<#119 (comment)<#119 (comment)>>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImFKlnCp8vO_AmD2Iy6qeDWf6jFcLks5u6bTxgaJpZM4S8ctb. 没看见您回复的图片,请问需要修改哪些配置?谢谢 ― You are receiving this because you commented. Reply to this email directly, view it on GitHub<#119 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImMoj2W2Z88qcaLnZnVf28lUnsJ-Wks5u6eoKgaJpZM4S8ctb.

问题已经解决,非常感谢您的帮忙。

abcadd commented 5 years ago

请问一下:配置文件中有邮件的相关配置,这个是接口改变的时候给团队的人发邮件通知吗?

15072314647 commented 5 years ago

并不是,通过看代码可以看出来,配置里的邮件配置是SMTP的设置;至于发给谁,是函数调用时需要指定的,猜测是与用户注册时有关; 源码位置:src/service/mail.ts

目前我猜测这里发邮件,只有在你重置账户时用到; 对应的代码位置:src/routes/account.ts

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: abcadd notifications@github.com 发送时间: Friday, December 21, 2018 2:55:47 PM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119)

请问一下:配置文件中有邮件的相关配置,这个是接口改变的时候给团队的人发邮件通知吗?

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/thx/rap2-delos/issues/119#issuecomment-449280157, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImGHWP9709TnCPIJhETwyGMhd4PEkks5u7IXzgaJpZM4S8ctb.

abcadd commented 5 years ago

并不是,通过看代码可以看出来,配置里的邮件配置是SMTP的设置;至于发给谁,是函数调用时需要指定的,猜测是与用户注册时有关; 源码位置:src/service/mail.ts 目前我猜测这里发邮件,只有在你重置账户时用到; 对应的代码位置:src/routes/account.ts 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用 ____ 发件人: abcadd notifications@github.com 发送时间: Friday, December 21, 2018 2:55:47 PM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119) 请问一下:配置文件中有邮件的相关配置,这个是接口改变的时候给团队的人发邮件通知吗? ― You are receiving this because you commented. Reply to this email directly, view it on GitHub<#119 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImGHWP9709TnCPIJhETwyGMhd4PEkks5u7IXzgaJpZM4S8ctb.

嗯嗯,谢谢。 对了,还请教一下:后台有没有用户、权限等设置,我没有看到

15072314647 commented 5 years ago

不好意思,不清楚!只知道后台的用户是通过数据库初始化插入的,权限没有发现; 表结构: Src/scripts/rap2_delos.sql 初始化数据文件: Src/scripts/init/delos.ts

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: abcadd notifications@github.com 发送时间: Friday, December 21, 2018 3:30:10 PM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119)

并不是,通过看代码可以看出来,配置里的邮件配置是SMTP的设置;至于发给谁,是函数调用时需要指定的,猜测是与用户注册时有关; 源码位置:src/service/mail.ts 目前我猜测这里发邮件,只有在你重置账户时用到; 对应的代码位置:src/routes/account.ts 发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用https://go.microsoft.com/fwlink/?LinkId=550986%3E%E5%BA%94%E7%94%A8____ 发件人: abcadd notifications@github.commailto:notifications@github.com 发送时间: Friday, December 21, 2018 2:55:47 PM 收件人: thx/rap2-delos 抄送: 15072314647; Comment 主题: Re: [thx/rap2-delos] 非官方rap2-delos部署文档 (#119https://github.com/thx/rap2-delos/issues/119) 请问一下:配置文件中有邮件的相关配置,这个是接口改变的时候给团队的人发邮件通知吗? D You are receiving this because you commented. Reply to this email directly, view it on GitHub<#119 (comment)https://github.com/thx/rap2-delos/issues/119#issuecomment-449280157>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImGHWP9709TnCPIJhETwyGMhd4PEkks5u7IXzgaJpZM4S8ctb.

嗯嗯,谢谢。 对了,还请教一下:后台有没有用户、权限等设置,我没有看到

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/thx/rap2-delos/issues/119#issuecomment-449290769, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqNImFpOyFQNyjTBio19QiuKucNuIeeGks5u7I4CgaJpZM4S8ctb.

jhooo commented 5 years ago

可以试试 redis: { host: '192.168.1.1', port: 6379, auth_pass: 'pass' },

abcadd commented 5 years ago

部署后端dev启动报错: (node:37238) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: session store is unavailable 大侠们有知道怎么回事的吗?

smjsmjsmj commented 5 years ago

rap2 redis 集群有配置步骤吗

xuqinglei commented 5 years ago

root@centos7server rap2-delos-master]# npm run create-db

rap2-delos@1.0.0 create-db /opt/rap2-delos-master cross-env NODE_ENV=development node dist/scripts/init

internal/modules/cjs/loader.js:583 throw err; ^

Error: Cannot find module '/opt/rap2-delos-master/dist/scripts/init' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! rap2-delos@1.0.0 create-db: cross-env NODE_ENV=development node dist/scripts/init npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the rap2-delos@1.0.0 create-db script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2019-03-07T09_33_36_878Z-debug.log

xuqinglei commented 5 years ago

npm run dev 怎么以后台的方式运行

alonesword commented 5 years ago

文档中的 Dockerfile 文件中因缺少 test\public 目录的 mv 命令,导致部署的 docker 版本,链接 test 时,会出现 404 错误,此问题需要修复 Dockerfile 文件部署命令。 已提供最新的修复命令: https://github.com/alonesword/rap2-delos/blob/master/Dockerfile

jy2029620 commented 5 years ago

想请教一下,登录或注册时提示“Unexpected token I in JSON at position 0”

lewis219 commented 5 years ago

ERROR: Cannot copy to clipboard: Command failed: xsel --clipboard --input xsel: Can't open display: (null) : Inappropriate ioctl for device

在启动前端的时候serve -s ./build -p 80报这个错误,有人有遇到过吗

xzxiaoshan commented 5 years ago

今天花了几个小时,刚刚写了一个Dockerfile,并且调试完成OK! 详见:https://github.com/xzxiaoshan/rap2-delos

msw1535540 commented 5 years ago

npm install报错: npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor. npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@ali%2fkeycenter - Not found npm ERR! 404 npm ERR! 404 '@ali/keycenter@^1.0.2' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 It was specified as a dependency of 'rap2-delos' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: npm ERR! /home/app/.npm/_logs/2019-06-04T05_08_36_685Z-debug.log