Appearance
安装指南
本指南详细介绍 Croupier 各组件的安装和配置方法。
目录
系统要求
最低要求
| 组件 | 最低版本 | 推荐版本 |
|---|---|---|
| Go | 1.26 | 1.26+ |
| Node.js | 22 | 22+ |
| pnpm | 10 | 10.22+ |
| buf | - | latest |
| 操作系统 | Linux/macOS/Windows | Linux/macOS |
硬件要求
| 场景 | CPU | 内存 | 磁盘 |
|---|---|---|---|
| 开发 | 2 核 | 4 GB | 10 GB |
| 生产(小规模) | 4 核 | 8 GB | 50 GB |
| 生产(大规模) | 8 核+ | 16 GB+ | 100 GB+ |
开发环境安装
1. 安装 Go
macOS
bash
# 使用 Homebrew
brew install go
# 验证安装
go versionLinux (Ubuntu/Debian)
bash
# 下载并安装
wget https://go.dev/dl/go1.26.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.26.2.linux-amd64.tar.gz
# 配置 PATH
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrcWindows
从 Go 官网 下载安装程序并运行。
2. 安装 Node.js 和 pnpm
bash
# 使用 fnm 安装 Node.js(推荐)
curl -fsSL https://fnm.vercel.app/install | bash
fnm install 22
fnm use 22
# 安装 pnpm
npm install -g pnpm
# 验证安装
node -v
pnpm -v3. 安装 buf
bash
# 使用 go install
go install github.com/bufbuild/buf/cmd/buf@latest
# 或使用 Homebrew(macOS)
brew install bufbuild/buf/buf
# 验证安装
buf --version4. 克隆项目
bash
# 克隆主仓库
git clone https://github.com/cuihairu/croupier.git
cd croupier
# 初始化子模块
git submodule update --init --recursive生产环境安装
Docker 部署
使用 Docker Compose
bash
# 构建镜像
docker compose build
# 启动服务
docker compose up -d
# 查看日志
docker compose logs -f单独部署
bash
# 构建 Server 镜像
docker build -t croupier-server:latest -f docker/Dockerfile.server .
# 运行 Server
docker run -d \
--name croupier-server \
-p 19090:19090 \
-p 18780:18780 \
-v $(pwd)/data:/app/data \
-v $(pwd)/configs:/app/configs \
croupier-server:latest二进制部署
下载预构建版本
从 Release 页面 下载对应平台的二进制文件。
从源码构建
bash
# 克隆仓库
git clone https://github.com/cuihairu/croupier.git
cd croupier
git submodule update --init --recursive
# 构建发布版本
make build-release
# 二进制文件位于 bin/ 目录
ls -la bin/SDK 安装
Go SDK
bash
go get github.com/cuihairu/croupier-sdk-go@latestC++ SDK
bash
# 使用 vcpkg
vcpkg install croupier-sdk-cpp
# 或从源码构建
cd sdks/croupier-sdk-cpp
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make installJava SDK
xml
<dependency>
<groupId>com.github.cuihairu</groupId>
<artifactId>croupier-sdk-java</artifactId>
<version>LATEST</version>
</dependency>JavaScript/TypeScript SDK
bash
# npm
npm install @croupier/sdk-js
# pnpm
pnpm add @croupier/sdk-js
# yarn
yarn add @croupier/sdk-jsPython SDK
bash
pip install croupier-sdk-python配置文件
Server 配置
yaml
name: croupier-server
host: 0.0.0.0
port: 18780 # HTTP 监听地址
control:
addr: ":19090" # Control 监听地址
database:
driver: postgres
dataSource: "postgres://user:pass@localhost:5432/croupier"
log:
level: info
format: jsonAgent 配置
yaml
name: croupier-agent
host: 0.0.0.0
port: 19091
server:
addr: "localhost:19090"
insecure: false
agent:
gameId: "my-game"
env: "dev"
localAddr: "localhost:19091"
outboundTLS:
enabled: true
caFile: "data/ca.crt"
certFile: "data/agent.crt"
keyFile: "data/agent.key"验证安装
健康检查
bash
# Server 健康检查
curl http://localhost:18780/healthz
# 预期输出
{"status":"ok"}功能测试
bash
# 运行单元测试
make test
# 运行集成测试
make test-integration故障排查
常见问题
Go 版本不兼容
确保 Go 版本为 1.26 或更高:
bash
go version如果不满足,请升级 Go 版本。
子模块为空
重新初始化子模块:
bash
git submodule deinit --all
git submodule update --init --recursivebuf 命令未找到
确保 $GOPATH/bin 在 PATH 中:
bash
export PATH=$PATH:$(go env GOPATH)/bin端口已被占用
修改配置文件中的端口:
yaml
control:
addr: ":19091"
port: 19080下一步
安装完成后,请参考:
