Add multi server deployment tutorial

This commit is contained in:
方块君 2022-07-26 20:47:25 +08:00
parent 9fe473d6cc
commit 2799a06312
2 changed files with 65 additions and 20 deletions

View File

@ -25,6 +25,20 @@
3. 重新启动服务端即可生效配置 3. 重新启动服务端即可生效配置
4. 在客户端中选择控制台身份,并填写你的 `consoleToken` 即可以控制台身份运行指令 4. 在客户端中选择控制台身份,并填写你的 `consoleToken` 即可以控制台身份运行指令
## 多服务器
### 主服务器 (Dispatch)
1. 在 `opencommand-plugin` 目录下打开 `config.json`
2. 修改 `socketPort` 值为一个未被使用的端口
3. 设置 `socketToken` 多服务器通信密钥建议使用至少32字符的长随机字符串。
4. 重新启动服务端即可生效配置
### 子服务器 (Game)
1. 在 `opencommand-plugin` 目录下打开 `config.json`
2. 修改 `socketHost``socketPort` 值为主服务器的地址和端口
3. 设置 `socketToken` 和主服务器相同的值
4. 设置 `socketDisplayName` 值为你的服务器名称 (用途请见[下方](https://github.com/jie65535/gc-opencommand-plugin#%E8%8E%B7%E5%8F%96%E5%A4%9A%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%88%97%E8%A1%A8))
5. 重新启动服务端即可生效配置
## 构建说明 ## 构建说明
1. 克隆仓库 1. 克隆仓库
@ -118,7 +132,6 @@ public final class JsonResponse {
| message | `Success` | `String` | | message | `Success` | `String` |
| data | `null` | `null` | | data | `null` | `null` |
#### `获取在线玩家` #### `获取在线玩家`
##### Request ##### Request
@ -242,13 +255,13 @@ public final class JsonResponse {
```json ```json
{ {
"retcode": 200, "retcode": 200,
"message": "success", "message": "success",
"data": { "data": {
// 服务器 UUID // 服务器 UUID
"13d82d0d-c7d9-47dd-830c-76588006ef6e": "2.8.0 服务器", "13d82d0d-c7d9-47dd-830c-76588006ef6e": "2.8.0 服务器",
"e6b83224-a761-4023-be57-e054c5bb823a": "2.8.0 开发服务器" "e6b83224-a761-4023-be57-e054c5bb823a": "2.8.0 开发服务器"
} }
} }
``` ```
@ -256,6 +269,8 @@ public final class JsonResponse {
##### Request ##### Request
> 如果为单服务器则无需填写服务器 UUID
| 请求参数 | 请求数据 | 类型 | | 请求参数 | 请求数据 | 类型 |
|--------|-----------|----------| |--------|-----------|----------|
| action | `command` | `String` | | action | `command` | `String` |

View File

@ -5,16 +5,36 @@
A plugin that opens the GC command execution interface for third-party clients A plugin that opens the GC command execution interface for third-party clients
## Server installation ## Server installation
1. Download the `jar` in [Release](https://github.com/jie65535/gc-opencommand-plugin/releases) 1. Download the `jar` in [Release](https://github.com/jie65535/gc-opencommand-plugin/releases)
2. Put it in the `plugins` folder 2. Put it in the `plugins` folder
## Console connection ## Console connection
1. When starting for the first time, a `opencommand-plugin` directory will be generated under the `plugins` directory, open and edit `config.json`
2. Set the value of `consoleToken` to your connection key. It is recommended to use a long random string of at least 32 characters. 1. When starting for the first time, a `opencommand-plugin` directory will be generated under the `plugins` directory,
open and edit `config.json`
2. Set the value of `consoleToken` to your connection key. It is recommended to use a long random string of at least 32
characters.
3. Restart the server to take effect 3. Restart the server to take effect
4. Select the console identity in the client, and fill in your `consoleToken` to run the command as the console identity 4. Select the console identity in the client, and fill in your `consoleToken` to run the command as the console identity
## Multi server
### Master server (Dispatch)
1. Open `config.json` in the `opencommand-plugin` directory
2. Modify the `socketPort` value to an unused port
3. Set the value of `socketToken` to your connection key. It is recommended to use a long random string of at least 32
characters.
4. Restart the server to make the configuration effective
### Sub server (Game)
1. Open `config.json` in the `opencommand-plugin` directory
2. Modify the `sockethost` and `socketport` values to the address and port of the primary server
3. Set the same value of `sockettoken` and the primary server
4. Set the `socketDisplayName` value to your server name (See below for usage [Jump](https://github.com/jie65535/gc-opencommand-plugin/blob/master/README_en-US.md#get-mulit-server-list))
5. Restart the server to make the configuration effective
## Build ## Build
1. `git clone https://github.com/jie65535/gc-opencommand-plugin` 1. `git clone https://github.com/jie65535/gc-opencommand-plugin`
2. `cd gc-opencommand-plugin` 2. `cd gc-opencommand-plugin`
3. `mkdir lib` 3. `mkdir lib`
@ -22,20 +42,24 @@ A plugin that opens the GC command execution interface for third-party clients
5. `gradle build` 5. `gradle build`
## Player ## Player
1. Fill in the service address in the client to confirm whether it supports 1. Fill in the service address in the client to confirm whether it supports
2. Fill in the UID and send the verification code 2. Fill in the UID and send the verification code
3. Fill in the **4-digit integer verification code** received in the game into the client verification 3. Fill in the **4-digit integer verification code** received in the game into the client verification
4. Enjoy the convenience! 4. Enjoy the convenience!
## Client request ## Client request
1. `ping` to confirm whether the `opencommand` plugin is supported 1. `ping` to confirm whether the `opencommand` plugin is supported
2. `sendCode` sends a verification code to the specified player (re-send is not allowed within 1 minute), and save the returned `token` 2. `sendCode` sends a verification code to the specified player (re-send is not allowed within 1 minute), and save the
returned `token`
3. Send `verify` check using `token` and **4-digit integer verification code** 3. Send `verify` check using `token` and **4-digit integer verification code**
4. If the verification is passed, you can use the `token` to execute the `command` action 4. If the verification is passed, you can use the `token` to execute the `command` action
--- ---
## `config.json` ## `config.json`
```json ```json
{ {
"consoleToken": "", "consoleToken": "",
@ -48,14 +72,16 @@ A plugin that opens the GC command execution interface for third-party clients
} }
``` ```
## API `/opencommand/api` ## API `/opencommand/api`
Example Example
``` ```
https://127.0.0.1/opencommand/api https://127.0.0.1/opencommand/api
``` ```
## Request ## Request
```java ```java
public final class JsonRequest { public final class JsonRequest {
public String token = ""; public String token = "";
@ -66,6 +92,7 @@ public final class JsonRequest {
``` ```
## Response ## Response
```java ```java
public final class JsonResponse { public final class JsonResponse {
public int retcode = 200; public int retcode = 200;
@ -75,6 +102,7 @@ public final class JsonResponse {
``` ```
### Actions ### Actions
#### `Test connect` #### `Test connect`
##### Request ##### Request
@ -214,13 +242,13 @@ Success
```json ```json
{ {
"retcode": 200, "retcode": 200,
"message": "success", "message": "success",
"data": { "data": {
// Server UUID // Server UUID
"13d82d0d-c7d9-47dd-830c-76588006ef6e": "2.8.0 Server", "13d82d0d-c7d9-47dd-830c-76588006ef6e": "2.8.0 Server",
"e6b83224-a761-4023-be57-e054c5bb823a": "2.8.0 Dev server" "e6b83224-a761-4023-be57-e054c5bb823a": "2.8.0 Dev server"
} }
} }
``` ```
@ -228,6 +256,8 @@ Success
##### Request ##### Request
> If it is a single server, there is no need to fill in server UUID.
| Request | Request data | Type | | Request | Request data | Type |
|---------|--------------|----------| |---------|--------------|----------|
| action | `command` | `String` | | action | `command` | `String` |