Files
center/scripts/build-games.sh
T
rong dd2935366e feat: 游戏中心——1818 单端口统一入口,进程按需拉起 + 空闲释放
- 一个端口按路径分发:/cnchess /cngo /cs 进程型,/alonelyroad /myword 静态目录
- 进程型首次访问以动态端口拉起子进程,就绪探测后转发;空闲 600s 且无 WS 连接才回收
- WebSocket 走原始 TCP 隧道(握手转发 + 101 透传 + 双向对拷,任一方向 EOF 即拆连)
- 文本响应就地重写根绝对路径(href/src/fetch/url(/ 与 location.host}/ws),游戏源码零改动
- 入口页只显示状态与进入入口,不提供管理按钮;网关/运维接口为 /api/*
- 配置 games.json 磁盘优先、内嵌兜底,改完刷新即生效
2026-10-23 10:09:06 +08:00

28 lines
715 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 把三个「进程型」游戏编成 release 单文件二进制。
# 游戏中心只在第一次访问时才拉起它们,所以先得有这么三个可执行文件。
set -euo pipefail
here="$(cd "$(dirname "$0")/.." && pwd)"
for g in cnchess cngo cs; do
dir="$here/../$g"
if [ ! -d "$dir" ]; then
echo "!! 找不到 $dir,跳过"
continue
fi
echo "==> 构建 $g($(basename "$dir"))"
( cd "$dir" && cargo build --release )
done
echo
echo "完成。二进制:"
for g in cnchess cngo cs; do
bin="$here/../$g/target/release/$g"
if [ -x "$bin" ]; then
printf ' %-10s %s\n' "$g" "$(du -h "$bin" | cut -f1)"
else
printf ' %-10s 缺失\n' "$g"
fi
done