- 一个端口按路径分发:/cnchess /cngo /cs 进程型,/alonelyroad /myword 静态目录 - 进程型首次访问以动态端口拉起子进程,就绪探测后转发;空闲 600s 且无 WS 连接才回收 - WebSocket 走原始 TCP 隧道(握手转发 + 101 透传 + 双向对拷,任一方向 EOF 即拆连) - 文本响应就地重写根绝对路径(href/src/fetch/url(/ 与 location.host}/ws),游戏源码零改动 - 入口页只显示状态与进入入口,不提供管理按钮;网关/运维接口为 /api/* - 配置 games.json 磁盘优先、内嵌兜底,改完刷新即生效
14 lines
332 B
Bash
Executable File
14 lines
332 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# 启动游戏中心:没有二进制就先编,然后前台跑在 1818。
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
bin="$here/target/release/game-center"
|
|
|
|
if [ ! -x "$bin" ]; then
|
|
echo "==> 首次运行,先编译 game-center"
|
|
( cd "$here" && cargo build --release )
|
|
fi
|
|
|
|
exec "$bin" "$@"
|