← Back to PRs

#6776: fix: CLI commands hang/fail on Fly.io deployments

by jckw open 2026-02-02 01:49 View on GitHub →
docs
## 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