Skip to content
6 changes: 6 additions & 0 deletions docs/develop/manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pwsh -NoProfile -File build.ps1 -Test # 先跑 go vet 和 go test
- 有一部分测试用 Python 3 运行 AUTO-MAS 的原始逻辑,和 Go 的输出逐字节对照,所以要装 Python 3;
- 实测要一个 ModAVD 根目录:Release 包解压,再补全组件;
- 实测用新建的实例、私有 adb 端口;
- 开发、测试用的根目录换一段端口:同一台电脑上还有日常在用的根目录(比如 AUTO-MAS 用的那个)时,在开发根目录的 `mas-avd.json` 里写 `"portBase": 21000`,这个根目录的实例就从 21000 起算端口,不和那边同编号的实例抢。要带 [ModAVD/ModAVD#75](https://github.com/ModAVD/ModAVD/issues/75) 的管理器。
- 端口:控制台 = `portBase` + 10 × 编号,adb 加 1,gRPC 加 2;编号还是 0–9,不含 5。`portBase` 只能是 20000(缺省),或者 1100–65400 之间 100 的整数倍;同时开两个开发根目录,第二个换一段,比如 23000。选之前先看一眼这一段有没有别的程序在用(比如 Syncthing 默认占着 22000)。
- `adbServerPort`、`scriptAdbServerPort` 也要配,不能是 20049、20050,也不能落在 20000 段实例的端口上。否则管理器不开机、不新建,也不去起或连 adb server。
- 改之前先关掉这个根目录的所有实例。AUTO-MAS 还不认 `portBase`,设了的根目录不要加进 AUTO-MAS。
- 不要对放着重要实例的根目录开实机测试开关(`MODAVD_TEST_LIVE=1`)。

CI 在 PR 上跑格式检查、`go vet`、`go test`、`build.ps1`、隐私扫描和作者检查。
Expand All @@ -47,6 +51,8 @@ CI 在 PR 上跑格式检查、`go vet`、`go test`、`build.ps1`、隐私扫描

`--json` 输出的信封、错误码和 `protocol` 版本是 AUTO-MAS 依赖的。加字段可以;改含义、删字段要把 `internal/buildinfo` 里的 `Protocol` 加一,先开 issue。

脚本要用实例的端口时,从 `list` / `info` / `status` 的 `ports`、`serial` 取,不要自己按 20000 + 10 × 编号算:设了 `portBase` 的根目录不在 20000 段上。`list` 的 `port_base` 是根目录实际用的端口段,旧版管理器没有这一项(只用 20000 段)。

## 版本

管理器从 v0.1.0 起单独编号、单独发版(v0.1.0 的两个 exe 和 ModAVD 0.36.0 包里的逐字节相同)。ModAVD 整包发版时钉住当时的管理器版本和哈希,整包里的那份跟着整包一起换。管理器不自更新:0.2.0 起的 `modavd update` 更新的是整个 ModAVD 根目录(来源 GitHub 或 Mirror 酱,只在手动运行时联网),单独下载的管理器要手动替换。
Expand Down
6 changes: 6 additions & 0 deletions docs/en/develop/manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ It uses `-trimpath -buildvcs=false` and does not write the version number with `
- Some tests run AUTO-MAS's original logic with Python 3 and compare it with Go's output byte by byte, so Python 3 must be installed;
- Testing on a real instance needs a ModAVD root folder: extract the release package, then fetch the Google components;
- Use newly created instances and a private adb port for these tests;
- Give root folders for development and testing their own port range: when the same computer also has a root folder in daily use (for example the one AUTO-MAS uses), write `"portBase": 21000` in the `mas-avd.json` of the development root folder. Its instances then count their ports from 21000 and do not fight with the instances of the same number over there. This needs a manager with [ModAVD/ModAVD#75](https://github.com/ModAVD/ModAVD/issues/75).
- Ports: console = `portBase` + 10 × index, adb is 1 more, gRPC 2 more; the index is still 0–9 without 5. `portBase` can only be 20000 (the default) or a multiple of 100 between 1100 and 65400. With two development root folders open at the same time, give the second another range, for example 23000. Before you pick one, check that no other program uses that range (Syncthing, for example, takes 22000 by default).
- Also set `adbServerPort` and `scriptAdbServerPort`. They cannot be 20049 or 20050, nor fall on the ports of an instance in the 20000 range. Otherwise the manager does not start or create instances, and does not start or connect to an adb server.
- Shut down every instance of the root folder before you change it. AUTO-MAS does not know `portBase` yet, so do not add a root folder that sets it to AUTO-MAS.
- Do not turn on the live-test switch (`MODAVD_TEST_LIVE=1`) against a root folder that holds important instances.

CI runs the format check, `go vet`, `go test`, `build.ps1`, the privacy scan and the author check on PRs.
Expand All @@ -47,6 +51,8 @@ CI runs the format check, `go vet`, `go test`, `build.ps1`, the privacy scan and

The envelope of the `--json` output, the error codes and the `protocol` version are what AUTO-MAS depends on. Adding fields is fine. To change a meaning or remove a field, add one to `Protocol` in `internal/buildinfo` and open an issue first.

When a script needs the ports of an instance, take them from `ports` and `serial` in `list` / `info` / `status` instead of computing 20000 + 10 × index: a root folder that sets `portBase` is not in the 20000 range. `port_base` in `list` is the port range the root folder actually uses; older managers do not have it (they only use the 20000 range).

## Versioning

The manager has been numbered and released separately since v0.1.0 (the two exe files of v0.1.0 are byte-identical to those in the ModAVD 0.36.0 package). When the ModAVD package is released, it pins the manager version and hash at that time, and the copy inside the package changes together with the package. The manager does not update itself: from 0.2.0, `modavd update` updates the whole ModAVD root folder (from GitHub or MirrorChyan, going online only when you run it by hand), and a manager downloaded on its own has to be replaced by hand.
Expand Down