非官方rap2-delos部署文档
BladeCode opened this issue · 56 comments
前言
RAP2 包含两个组件 客户端:rap2-dolores 和 服务端:rap2-delos
部署RAP2需要亲具有Node+Linux+MySQL的运维知识,如果亲对此不是很了解,建议用http://rap2.taobao.org 线上版本就可以了。
构建项目
安装基本工具
- Git
- Node 8.9.4+
- MySQL 5.7+
- VS Code(非必需)
以上基本工具请根据自身需要,下载对应系统安装包,请自行解决安装配置等问题,这里不做过多说明
获取源代码
git clone https://github.com/thx/rap2-delos.git
导入VS Code
这里的开发编辑工具推荐,当然你也可以用自己熟悉的开发工具
环境配置
创建数据库
-
Mac or Linux
mysql -e 'CREATE DATABASE IF NOT EXISTS RAP2_DELOS_APP DEFAULT CHARSET utf8 COLLATE utf8_general_ci';
-
Windows 环境
进入mysql命令后执行
CREATE DATABASE IF NOT EXISTS RAP2_DELOS_APP DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
配置文件
目录:rap2-delos/src/config
文件:config.dev.ts
;其中dev,表示开发环境,其他同理
修改:config.dev.ts
文件中db
对象中username
,password
参数与本地或者开发环境的数据库信息匹配
启动项目
安装项目依赖包
项目根目录下执行
npm install
如果下载缓慢,请使用淘宝npm镜像
初始化数据库
项目根目录下执行
npm run create-db
编译启动项目
执行mocha测试用例和js代码规范检查
npm run check
- 开发模式
启动开发模式的服务器 监视并在发生代码变更时自动重启npm run dev
- 生产模式
启动生产模式服务器npm start
看到浏览器中如下提示,表示服务端delos已经部署成功
RAP2后端服务已启动,请从前端服务(rap2-dolores)访问。 RAP2 back-end server is started, please visit via front-end service (rap2-dolores).
常见问题
部署问题
-
Windows下执行
npm run build
,提示'rm' 不是内部或外部命令,也不是可运行的程序或批处理文件
原因:
rm
是Linux下命令,
解决方法:Windows系统可使用git bash
打开该项目,执行该命令 -
执行
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/
@BladeCode 你好,这代码中没有dist/目录文件,项目无法运行!请问您是怎么处理的?
@jeffhuang2086 看看package.json,运行 npm run build 就可以启动 ts 编译,把源文件编译到 dist 文件夹里面,就有 dist/ 目录了。
咨询下,版本升级中怎么应对数据库的部分?需要每个表比对吗?
赞👍
@WeekiXu 版本升级,一般在Database/文件夹下有不同版本的数据库改动SQL脚本。
v2.5之后的我都放这里了,v2.5之前不是我写的.... 不过我方出来公开到github上就已经2.5了
静态资源使用nginx部署的,接口请求如何代理到后台服务?
@Bosn 有docker部署方案么
centos部署,浏览器中访问端口提示:RAP2后端服务已启动,请从前端服务(rap2-dolores)访问。 RAP2 back-end server is started, please visit via front-end service (rap2-dolores).
接下来还要部署前端项目吗?要是部署的话,在什么地方下载啊?
@silencenight 老哥文档里有啊。https://github.com/thx/rap2-dolores
你问这个问题,维护的人真是要忙死。
开始部署了。
@Bosn 数据库表( Table 'RAP2_DELOS_APP.Users' doesn't exist)好像跟1也有点出入,如果正式开源是否也可以方便提供
文档写的没有官方的详细,有坑
npm install之后要先执行npm run build,否则没有dist目录
今天捣鼓了很久,终于部署完毕
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
rap2-dolores 客户端执行了npm run build以后,怎么代理呢?能不能发一份你的nginx配置文件。
@Haphets
server
{
listen 80;
server_name rap2.xxxxxx.com;
root /mnt/www/rap_api/rap2-dolores/build;
location / {
try_files $uri /index.html;
}
}
请问此项目如何改变打包的路径?此前一直在使用webpack的项目,对非webpack项目打包不熟悉。我在package.json中添加homepage属性后只能修改当时引入的js,懒加载的js文件无法修改成功。请问如何解决?
delos初始化数据库的时候,插入数据库的基础数据里面的中文都是乱码的,怎么解决呢?
windows下 npm start, 停止不了了, 怎么回事? 开了一堆node窗口, 任务管理器中结束进程树不行, 找到8080端口的pid, 结束进程还是不行, 是什么情况? 难道要重启机器?
redis使用了密码, 在npm run create-db的时候就报错了, 修改了配置文件 src/config/config.dev.ts 的redisOptions.password 选项, 还是报错, 好像还是权限问题, 有遇到的吗?
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
解决了,配置文件的数据库没改,用的默认的,默认的那个不对,看了好几遍才找到原因,尴尬 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配置需不需要改啊?
请问下 delos bulid. prod的环境变量是在哪里设置的呢? 我想用process.env 但是没找到配置的地方啊
redis使用了密码, 在npm run create-db的时候就报错了, 修改了配置文件 src/config/config.dev.ts 的redisOptions.password 选项, 还是报错, 好像还是权限问题, 有遇到的吗?
请问redis有密码怎么处理啊?解决了吗
@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的密码
}
请问redis集群的配置怎么写?
[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.
没看见您回复的图片,请问需要修改哪些配置?谢谢
说明放到我的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](https://go.microsoft.com/fwlink/?LinkId=550986%E5%BA%94%E7%94%A8https://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.
问题已经解决,非常感谢您的帮忙。
请问一下:配置文件中有邮件的相关配置,这个是接口改变的时候给团队的人发邮件通知吗?
并不是,通过看代码可以看出来,配置里的邮件配置是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.
嗯嗯,谢谢。
对了,还请教一下:后台有没有用户、权限等设置,我没有看到
可以试试
redis: {
host: '192.168.1.1',
port: 6379,
auth_pass: 'pass'
},
部署后端dev启动报错:
(node:37238) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: session store is unavailable
大侠们有知道怎么回事的吗?
rap2 redis 集群有配置步骤吗
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
npm run dev 怎么以后台的方式运行
文档中的 Dockerfile 文件中因缺少 test\public 目录的 mv 命令,导致部署的 docker 版本,链接 test 时,会出现 404 错误,此问题需要修复 Dockerfile 文件部署命令。
已提供最新的修复命令:
https://github.com/alonesword/rap2-delos/blob/master/Dockerfile
想请教一下,登录或注册时提示“Unexpected token I in JSON at position 0”
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报这个错误,有人有遇到过吗
今天花了几个小时,刚刚写了一个Dockerfile,并且调试完成OK!
详见:https://github.com/xzxiaoshan/rap2-delos
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
npm install报错:
npm ERR! TypeError: Cannot read property 'latest' of undefined
npm ERR! at next (/usr/local/node/0.10.24/lib/node_modules/npm/lib/cache.js:688:35)
npm ERR! at /usr/local/node/0.10.24/lib/node_modules/npm/lib/cache.js:676:5
npm ERR! at saved (/usr/local/node/0.10.24/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/local/node/0.10.24/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/isaacs/npm/issues
有大佬知道原因吗?
windows下 npm start, 停止不了了, 怎么回事? 开了一堆node窗口, 任务管理器中结束进程树不行, 找到8080端口的pid, 结束进程还是不行, 是什么情况? 难道要重启机器?
pm2 delete 0 好像npm start有很多问题,只能用dev
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/initinternal/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
同样的问题
https://github.com/taomaree/docker-rap2 这个 docker-compose up -d 直接安装
Starting the development server...
Failed to compile.
F:/rap2-dolores/src/components/common/Select.tsx
TypeScript error in F:/rap2-dolores/src/components/common/Select.tsx(78,34):
Generic type 'NoticeProps' requires 2 type argument(s). TS2314
76 | )
77 |
78 | function NoOptionsMessage(props: NoticeProps) {
| ^
79 | return (
80 | <Typography
81 | color="textSecondary"
Windows10这是什么错误啊,编译失败