#6776: fix: CLI commands hang/fail on Fly.io deployments
docs
Cluster:
Docker and Deployment Improvements
## Summary
- Fix CLI commands connecting to wrong port on Fly.io (defaulting to 18789 instead of 3000)
- Fix CLI commands hanging after completion due to lingering event loop handles
- Update Fly.io docs with new env var and troubleshooting section
## Changes
1. **fly.toml**: Added `OPENCLAW_GATEWAY_PORT = "3000"` so CLI commands know which port the gateway uses
2. **src/index.ts**: Added explicit `process.exit(0)` after `parseAsync` resolves (long-running commands like `gateway run` are unaffected as they never resolve)
3. **docs/platforms/fly.md**: Updated example config and added troubleshooting section
## Test plan
- [ ] Deploy to Fly.io with updated config
- [ ] Run `fly ssh console -C "cd /app && node dist/index.js devices list"` - should connect and exit cleanly
- [ ] Run `fly ssh console -C "cd /app && node dist/index.js --help"` - should print help and exit
- [ ] Verify gateway still runs normally (doesn't exit prematurely)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates Fly.io deployment guidance and runtime behavior so CLI commands work reliably on Fly machines:
- Adds `OPENCLAW_GATEWAY_PORT=3000` to Fly config examples so CLI subcommands connect to the correct gateway port instead of the default `18789`.
- Forces process termination after `commander`’s `parseAsync()` resolves to prevent short-lived CLI commands from hanging due to lingering event-loop handles.
- Expands Fly.io docs with a troubleshooting entry for CLI connection/hang issues.
The change in `src/index.ts` affects the top-level CLI entrypoint used by most commands; long-running commands are expected not to resolve `parseAsync()` and therefore won’t hit the explicit exit.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe but has a notable risk of prematurely terminating short-lived commands via `process.exit(0)`.
- Docs/env var changes are low risk, but unconditionally calling `process.exit(0)` after `parseAsync()` resolves can truncate output or skip async cleanup/log flushing depending on what handlers are still in flight when the command finishes.
- src/index.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#14712: New files from Fly.io Launch
by Sandro-AAA · 2026-02-12
79.9%
#12987: fix(cli): exit process after successful command completion
by omair445 · 2026-02-10
79.6%
#15306: fix: explicit exit after onboarding command completes
by jeroenbaas · 2026-02-13
78.3%
#8260: fix(macOS): gateway readiness detection + reversible Configure later
by xksteven · 2026-02-03
73.7%
#17331: Documentation missing fly io --app flag when creating volume
by charlietlamb · 2026-02-15
73.6%
#16707: Claude/review deployment setup wbbcc
by absurdfounder · 2026-02-15
72.5%
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
72.5%
#6638: fix: make Dockerfile work on container platforms (Render, Railway, ...
by kaizen403 · 2026-02-01
72.5%
#10367: CLI/Ops: resilient browser fill + failover hardening + operations t...
by cluster2600 · 2026-02-06
72.2%
#5823: fix(config): exit cleanly on invalid config instead of high CPU loop
by gavinbmoore · 2026-02-01
72.0%