Skip to content

fix(start.sh): 后台 detach 启动,修复 Code 模块 Offline - #55

Merged
dahai80 merged 2 commits into
mainfrom
fix/start-sh-background
Aug 7, 2026
Merged

fix(start.sh): 后台 detach 启动,修复 Code 模块 Offline#55
dahai80 merged 2 commits into
mainfrom
fix/start-sh-background

Conversation

@dahai80

@dahai80 dahai80 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

背景

Closes #54

点击 Fusion-Studio 的 Code 菜单,第三列显示 Offline,端口 11441 不监听。

根因

start.sh 末尾 exec ./fusion-code --serve前台启动,进程不退出。Studio 的 UpstreamServiceManager.runStartShstart.sh start 设 30s 超时强制 terminate,前台 exec 不返回 → 30s 后连同刚启动的服务一起被杀 → 健康探测失败 → Offline。

修复

参考 fusion-projects/start.sh 模式,改为后台 detach:

  • nohup ./fusion-code --serve ... & + 写 PID 文件 .fusion-code.pid
  • 子命令 start|stop|status|restartstart 立即返回
  • 日志输出到 logs/stdout.log / logs/stderr.log
  • stop 优雅停 + 5s 后强杀兜底

验证

./start.sh start     # 立即返回 exit 0,服务后台存活
# 模拟 Studio 30s 超时杀掉 bash start.sh start 调用者
lsof -iTCP:11441     # 服务仍在监听
curl 127.0.0.1:11441/api/model/status   # 200
./start.sh stop      # 优雅停止

启动后即使调用进程被终止,服务仍存活——这是修复的关键点。

🤖 Generated with Claude Code

dahai80 and others added 2 commits August 7, 2026 11:41
start.sh 原用 exec 前台启动 fusion-code,进程不退出。
Fusion-Studio UpstreamServiceManager.runStartSh 对 start.sh start 设 30s
超时强制 terminate,前台 exec 不返回 → 30s 后连同刚启动的服务一起被杀,
Code 模块显示 Offline。

改为参考 fusion-projects/start.sh:nohup 后台 + PID 文件 + start|stop|status|restart
子命令。start 立即返回,服务 detach 存活;stop 按 PID 文件优雅停 + 强杀兜底。

Closes #54

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR #55 的 start.sh 后台 detach 会生成 .fusion-code.pid 与 logs/ 目录,
未加入 .gitignore 会污染工作树 (当前 .fusion-code.pid 已出现在 untracked)。
补齐忽略规则。

Co-Authored-By: Claude <noreply@anthropic.com>
@dahai80
dahai80 merged commit bffb0e2 into main Aug 7, 2026
1 check passed
@dahai80
dahai80 deleted the fix/start-sh-background branch August 7, 2026 09:26
dahai80 added a commit that referenced this pull request Aug 7, 2026
补丁版本:
- fix(start.sh): 后台 detach (nohup) 启动,新增 start|stop|status|restart 子命令,
  PID 文件 + 日志目录管理,避免被 Studio 30s 超时连带终止,修复 Code 模块 Offline (#55)
- chore: gitignore start.sh 运行时产物 (.fusion-code.pid, logs/)

测试: tsc=0, biome=0 error, 345 tests pass, build OK, --version=0.4.16
CI: PR #55 success

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

start.sh 前台 exec 导致 Fusion-Studio 自动启动 30s 后被杀,Code 模块显示 Offline

1 participant