27 lines
1.1 KiB
Markdown
27 lines
1.1 KiB
Markdown
# 环境搭建
|
|
- 安装 ts 环境
|
|
`npm install -g tsc ts-node typescript`
|
|
- 安装 pinus
|
|
`npm install -g pinus`
|
|
|
|
# 运行
|
|
## 简介
|
|
服务器主要分为游戏服和账号服,游戏服以长连接为主,处理主要的游戏逻辑。账号服以短连接为主,处理账号等功能。
|
|
|
|
## 运行游戏服
|
|
`cd game-server && node tsrun.js`
|
|
|
|
## 运行 web-server
|
|
`cd web-server && node app`
|
|
|
|
## 扩容事项
|
|
1.master.ts对应环境的主机host填写内网ip地址,新服务器host填写主机host地址
|
|
2.config/database.ts填写对应环境下的配置
|
|
3.新服务器执行命令(host为主机内网ip)
|
|
4.id绝不能重复
|
|
5.connector服务的clientPort端口需暴露,必须加frontend=true
|
|
6.扩容脚本./pm2StarterDistribute.sh
|
|
7.手输命令示例如下:
|
|
`pm2 start ./dist/app.js --name="activity-server-2" -x -- env=dev id=activity-server-2 host=172.26.145.171 port=9061 serverType=activity`
|
|
`pm2 start ./dist/app.js --name="connector-server-4" -x -- env=dev id=connector-server-4 host=172.26.145.171 port=9062 clientHost=121.89.211.172 clientPort=3050 serverType=connector frontend=true`
|