Mosaic CLI 文档 EN

Gateway

Gateway 模块:一步一步教程

用于管理网关生命周期,并通过 CLI 验证方法调用接口。

步骤 1:安装本地网关运行时

mosaic --project-state gateway install --host 127.0.0.1 --port 8787

步骤 2:启动网关进程

mosaic --project-state gateway start
# 显式 host/port
mosaic --project-state gateway start --host 127.0.0.1 --port 8787

步骤 3:查看状态与健康

mosaic --project-state gateway status
mosaic --project-state gateway status --deep
mosaic --project-state gateway health
mosaic --project-state gateway health --verbose
mosaic --project-state gateway health --verbose --repair

步骤 4:探测与发现

mosaic --project-state gateway probe
mosaic --project-state gateway discover

步骤 5:执行 call 接口

mosaic --project-state gateway call status
mosaic --project-state gateway call status --params '{"detail":true}'
mosaic --project-state --json gateway call status

call 会把 method 与可选 JSON params 透传到当前网关服务。

步骤 6:执行端到端诊断

mosaic --project-state gateway diagnose --method status
mosaic --project-state --json gateway diagnose --method status --params '{"detail":true}'

diagnose 会依次执行 probe -> discover -> call,并输出每一步的健康状态、耗时和错误码。

步骤 7:重启与停机

mosaic --project-state gateway restart
mosaic --project-state gateway stop

步骤 8:清理卸载

mosaic --project-state gateway uninstall

步骤 9:运维验收清单

  • statushealthprobe 全部成功。
  • diagnose 在稳定环境下应为 failed=0。
  • 当端点不可达时,可用 gateway health --repair 做一次自动恢复。
  • call status 返回可用于自动化消费的有效结果。
  • 重启后网关仍保持健康。