Repository navigation
Closed
Description
nohup: ignoring input
2026-11-09T20:55:38.537+0800 INFO cli/serve.go:37 starting sctl serve {"version": "0.4.0"}
2026-11-09T20:55:38.564+0800 INFO daemon/component.go:81 bridge daemon is listening {"address": "127.0.0.1:8643", "jsonrpc": "2.0"}
2026-11-09T20:55:38.566+0800 INFO cago@v0.0.0-20260715061808-cfde8cba47ae/registry.go:103 sctl is starting...
{"level":"error","ts":"2026-11-09T20:15:27.017+0800","caller":"daemon/component.go:77","msg":"failed to bind the websocket listener","address":"127.0.0.1:8643","error":"listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
{"level":"error","ts":"2026-11-09T20:33:41.206+0800","caller":"daemon/component.go:77","msg":"failed to bind the websocket listener","address":"127.0.0.1:8643","error":"listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
{"level":"error","ts":"2026-11-09T20:42:41.688+0800","caller":"daemon/component.go:77","msg":"failed to bind the websocket listener","address":"127.0.0.1:8643","error":"listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
{"level":"error","ts":"2026-11-09T20:51:40.755+0800","caller":"daemon/component.go:77","msg":"failed to bind the websocket listener","address":"127.0.0.1:8643","error":"listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
{"level":"info","ts":"2026-11-09T20:42:41.667+0800","caller":"cli/serve.go:37","msg":"starting sctl serve","version":"0.3.0"}
{"level":"error","ts":"2026-11-09T20:42:41.688+0800","caller":"daemon/component.go:77","msg":"failed to bind the websocket listener","address":"127.0.0.1:8643","error":"listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
{"level":"info","ts":"2026-11-09T20:49:56.913+0800","caller":"cli/serve.go:37","msg":"starting sctl serve","version":"0.4.0"}
{"level":"info","ts":"2026-11-09T20:49:56.938+0800","caller":"daemon/component.go:81","msg":"bridge daemon is listening","address":"127.0.0.1:8643","jsonrpc":"2.0"}
{"level":"info","ts":"2026-11-09T20:49:56.939+0800","caller":"cago@v0.0.0-20260715061808-cfde8cba47ae/registry.go:103","msg":"sctl is starting..."}
{"level":"info","ts":"2026-11-09T20:51:40.732+0800","caller":"cli/serve.go:37","msg":"starting sctl serve","version":"0.4.0"}
{"level":"error","ts":"2026-11-09T20:51:40.755+0800","caller":"daemon/component.go:77","msg":"failed to bind the websocket listener","address":"127.0.0.1:8643","error":"listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
{"level":"info","ts":"2026-11-09T20:55:38.537+0800","caller":"cli/serve.go:37","msg":"starting sctl serve","version":"0.4.0"}
{"level":"info","ts":"2026-11-09T20:55:38.564+0800","caller":"daemon/component.go:81","msg":"bridge daemon is listening","address":"127.0.0.1:8643","jsonrpc":"2.0"}
{"level":"info","ts":"2026-11-09T20:55:38.566+0800","caller":"cago@v0.0.0-20260715061808-cfde8cba47ae/registry.go:103","msg":"sctl is starting..."}
2026-11-10T17:13:40.992+0800 INFO cli/serve.go:37 starting sctl serve {"version": "0.4.0"}
2026-11-10T17:13:41.011+0800 ERROR daemon/component.go:77 failed to bind the websocket listener {"address": "127.0.0.1:8643", "error": "listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
panic: start component error: *daemon.daemonComponent listen tcp 127.0.0.1:8643: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
goroutine 1 [running]:
github.com/cago-frame/cago.(*Cago).RegistryCancel(0x3399549e1ba8, {0x7ff6fdb6a6b0, 0x3399546103c0})
github.com/cago-frame/cago@v0.0.0-20260715061808-cfde8cba47ae/registry.go:59 +0x22e
github.com/scriptscat/sctl/internal/cli.newServeCmd.func1(0x3399548d6908?, {0x7ff6fe0b04a0?, 0x0?, 0x7ff6fdaf7d51?})
github.com/scriptscat/sctl/internal/cli/serve.go:39 +0x2c5
github.com/spf13/cobra.(*Command).execute(0x3399548d6908, {0x7ff6fe0b04a0, 0x0, 0x0})
github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb14
github.com/spf13/cobra.(*Command).ExecuteC(0x3399548d6608)
github.com/spf13/cobra@v1.10.2/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(0x3399545e9ef8?)
github.com/spf13/cobra@v1.10.2/command.go:1071 +0x13
main.main()
github.com/scriptscat/sctl/cmd/sctl/main.go:15 +0x1c
serve 和 service install 均报错,使用connect提示未启动,检测不到。
error: cannot connect to the sctl daemon; start it with `sctl serve`
查询占用,只有 sctl.exe 占用端口,结束后即释放,但启动后又提示占用。
Metadata
Metadata
Assignees
Labels
No labels
Activity
JsonSong89 commentedon Nov 11, 2026
补一份 100% 可复现的同类场景 + 根因定位(Windows 10、sctl 0.4.0)。
复现步骤
sctl service install→ 注册 Task Scheduler 用户级任务\sctl,后台 daemon 起来(ParentProcessId是任务计划程序宿主)。sctl serve:根因
端口被自己的另一个实例占着,不是残留进程也不是别的软件:
也就是
sctl service install启动的服务实例。此时sctl service status/sctl status都是正常的(daemon 0.4.0 running、浏览器在线),只有第二个serve抢不到端口。这条路径特别容易被触发:装了服务之后,用户按
sctl connect的提示(start it with sctl serve)或按旧习惯手动起 daemon,就会直接吃一坨 goroutine 栈。建议
serve绑定失败时不要panic:先用 control API 探测该地址——能拿到 sctl 的应答就打印daemon already running at 127.0.0.1:8643 (service \sctl)并提示sctl service status|restart,正常退出或返回明确的非零码;端口被非 sctl 进程占用时给出
address already in use (pid N, name),exit 1。sctl service install时若已有 daemon 在跑,先接管/重启,而不是留下「服务已装、连不上」的中间态。panic发生在cago.New(...).Start()内部,newServeCmd的RunE(serve.go:38-40)根本接不到,建议把 bind 失败转成RunE返回的 error,main统一按错误码退出。环境:Windows 10 Pro / sctl 0.4.0(commit
cba61950, go1.26.3 windows/amd64)/ Chrome 152 + sctl Browser 扩展 0.2.0。CodFrm commentedon Nov 12, 2026
感谢反馈,我看看
CodFrm commentedon Nov 12, 2026
感谢两位的反馈和定位,修复在 #21。
根因:
sctl serve绑定端口这一步原来放在 cago 组件的启动阶段,cago 遇到组件启动失败会直接 panic。所以只要端口被占,不管占着的是sctl service起的 daemon 还是别的程序,都会打印一屏 goroutine 栈,退出码 2。这个问题跟平台无关,macOS、Windows、Linux 上都能稳定复现。修复后:
serve先绑定端口,绑定失败时用健康检查判断是谁占着:error: an sctl daemon is already running at 127.0.0.1:8643, so there is nothing to start;sctl statusshows it, andsctl service statustells whether it is the background serviceerror: cannot listen on 127.0.0.1:8643 (free it or pick another address with --listen-address): listen tcp 127.0.0.1:8643: bind: …两种情况退出码都是 3,原因同时写进日志文件。保持非零退出码是有意的:服务管理器会继续重试,等前台的 daemon 退出后,服务能自动接上。已经在 Windows 11(Task Scheduler 服务占着 8643 时手动
sctl serve)、macOS 和 Linux(systemd 用户服务)上实机验证过。关于建议里的第 2 点:现有逻辑已经处理了。服务还没装、但已经有 daemon 在跑时,
sctl service install会直接拒绝;服务已经装过时,会先停掉旧实例再重新启动。修复会在下个版本发布,PR 合并后这个 issue 会自动关闭。原帖提到的「端口被 sctl.exe 占着,但
sctl connect提示 daemon 没启动」这一点我没能复现。如果升级后还遇到,麻烦附上sctl status和sctl service status的输出重新打开 issue,我们再看。YujiaCheng1996 commentedon Nov 13, 2026
如果仅仅是重复启动服务报端口号占用不是问题,只是根本无法启动成功,0.4.0在macos下测试没有任何问题,仅在windows11下无法成功启动。
尝试一个终端中启动sctl
立即在另一个终端中查询端口占用和状态
再次查询端口已经不再占用,但任务管理器中5092的进程仍在运行,第一个终端中仍然卡在starting,没有报错和退出
sctl.log内容如下,没有其他log
最后多次测试,是被adguard影响,将sctl设置为不通过adguard路由即可,macos的adguard/little snitch不影响sctl工作。
抱歉,这个issue可以关闭了。
🐛 端口上有程序在监听却不像 sctl daemon 时,不再说 daemon 没在运行
🐛 sctl serve 启动失败不再 panic,daemon 在跑却连不上时说清原因 (#21)