Town CLI

town public

管理 Console 的持久化公网暴露模式

town public

town public 用来管理 Console 的持久化公网暴露模式。

这个命令只控制 Console / Town gateway 的监听绑定方式,不会改动单个 agent 的监听行为。

用法

town public
town public status
town public on
town public on --host 0.0.0.0
town public off

action

  • 不带 action:在 TTY 中打开交互式公网模式管理器
  • status:查看持久化公网模式和当前 Console 运行状态
  • on:开启持久化公网模式
  • off:关闭持久化公网模式

常用参数

  • --host <host>:开启公网模式时使用的绑定 host,默认 0.0.0.0

关键行为

  • town public on 会保存持久化配置,后续 town starttown console start 会自动沿用这个公网模式。
  • 如果 Console 当前正在运行,执行 town public ontown public off 会自动重启 Console,让新的绑定立即生效。
  • 显式传入的运行时参数优先级更高。例如 town console start --host 127.0.0.1 会覆盖本次启动的持久化公网配置。
  • town public 只管理 Console 的对外暴露,不是所有 runtime 端口的全局开关。

典型流程

# 1) 先看当前持久化模式
town public status

# 2) 为后续启动开启公网暴露
town public on

# 3) 或者固定成自定义 host
town public on --host 10.0.0.5

# 4) 然后按正常方式启动 Town
town start

# 5) 需要恢复本机模式时关闭
town public off

相关命令