feat(cli): give the foreground Server a stable default port - #7
Merged
Merged
Conversation
`localapp server run` asked the OS for an ephemeral port on every start, so the address changed on each restart. Anything that has to name the Server — a saved profile, a reverse proxy, a published container port, or a terminal that keeps one process alive — could not pin it, and the port a running Server reported had to be copied by hand into every client. Default to 50524 and keep `--port` as the override, including `--port 0` for callers that really want an ephemeral port. The container image already passes an explicit port, so its behaviour is unchanged. The foreground mode is also a first-class way to run a personal Server when a fixed address matters or when the machine cannot register a scheduled task: docs/local-runtime.md now says so next to the daemon path. Verified on the packaged build: no arguments listens on 127.0.0.1:50524 with /health answering 200, and `--port 55441` moves it there and releases 50524.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
按「放弃 daemon、改用显式前台进程 + 固定端口」的决定改的:给前台 Server 一个稳定的默认端口。
改了什么
localapp server run原来每次都让系统分配临时端口(--port默认0),于是每次重启地址都变——已保存的 profile、反向代理、容器端口映射、以及「终端里显式养一个进程」这种用法都没法钉住它,只能每次把实际端口抄进客户端。--port保持为覆盖手段(含--port 0,给确实想要临时端口的人)(default: 50524),并加了一条固定端口的示例--port 3000,行为不变docs/local-runtime.md:前台模式现在被写成与 daemon 并列的正式用法,说明它适合需要稳定地址、或本机无法注册计划任务的机器实测(打包产物,真机)
单测
keeps one stable default port unless the operator asks for another断言三次调用的--port依次是50524 / 55441 / 0;tsc --noEmit通过。顺带更正一处外部诊断(避免报错 bug)
上一轮的反馈里说「
localapp server start在这台机器上失败,是因为平台模板 XML 的<Principal>缺<UserId>」——这条不成立。我在同一台机器上做过对照实验:LogonType换成 InteractiveToken/Password、加/不加UserId共 5 种组合 → 全部被拒schtasks /Create /TN … /TR "cmd /c exit" /SC ONLOGON→ 同样被拒Register-ScheduledTask(另一套 API)→ 同样被拒而
schtasks /Query、/Run、/End在普通权限下都能用。所以限制是这台机器对非提权令牌一律拒绝创建计划任务,与 XML 内容无关;注册成功的那些任务里UserId是由schtasks自己补写的。这条不必给 localapp 报 bug。(不过既然决定不用 daemon 了,这条路径在这台机器上是否可用已不影响你们。)
未包含
反馈里提到「localapp 0.2.8 里 sql.js 的 WASM 越界仍然存在」——那才是你们那台 Server 会死的原因,我这次没有验证也没有动它。如果要处理,我需要复现步骤或崩溃时的日志/复现条件。