Skip to content

Gateway - Add port-hint cli arg to enable restarting on the same port - #168

Merged
awheeler294 merged 2 commits into
masterfrom
restart-gateway-on-same-port
Oct 23, 2026
Merged

awheeler294 merged 2 commits into
masterfrom
restart-gateway-on-same-port

Conversation

@awheeler294

Copy link
Copy Markdown
Contributor

Summary

Add a --port-hint argument to allow the gateway to restart on the port it was previously using.

Currently, if a port is not specified in the config, the Gateway binds to a random unused port. This is the default and new-install state. When the gateway restarts, it binds to a different port, and the web UI can't reconnect to it. As part of the effort to make changing settings in the UI seamless, we want the gateway and web UI to be able to reconnect after a restart.

Changes

  • Add --port-hint. The gateway will try to connect to this port if no port is specified in the config. If it can't bind to this port it will fall back to any available port
  • Add a bind.rs file that handles the binding logic
  • Modify runner.rs and thread.rs to use the new code

It's better for the Gateway to restart on a different port then to fail to restart, so --port-hint works on a best-effort basis.

User Facing

Nothing uses --port-hint yet, that comes in the next commit.

Since --port-hint is best-effort only, it's an internal-only flag for now. In the future we might add a stronger version for the public, or decide to expose it as-is.

@awheeler294 awheeler294 self-assigned this Oct 22, 2026
@awheeler294 awheeler294 added the Gateway A separate product used by PromptForge label Oct 22, 2026
Comment thread crates/gateway/app/src/runner/bind-tests.rs
Comment thread crates/gateway/app/src/runner.rs Outdated
Comment thread crates/gateway/app/src/runner.rs
awheeler294 and others added 2 commits October 23, 2026 14:37
… port

Summary:

Add a `--preferred-port` argument to allow the gateway to restart on the port it
was previously using.

Currently, if a port is not specified in the config, the Gateway binds
to a random unused port. This is the default and new-install state. When
the gateway restarts, it binds to a different port, and the web UI
can't reconnect to it. As part of the effort to make changing settings
in the UI seamless, we want the gateway and web UI to be able to reconnect
after a restart.

Changes:

- Add `--preferred-port`. The gateway will try to connect to this port if no
  port is specified in the config. If it can't bind to this port it will
  fall back to any available port
- Add a `bind.rs` file that handles the binding logic
- Modify `runner.rs` and `thread.rs` to use the new code

It's better for the Gateway to restart on a different port then to fail
to restart, so `--preferred-port` works on a best-effort basis.

User Facing:

Nothing uses `--preferred-port` yet, that comes in the next commit.

Since `--preferred-port` is best-effort only, it's an internal-only flag for
now. In the future we might add a stronger version for the public, or
decide to expose it as-is.
Declare the windows-sys Gdi feature the gateway tray uses

tokio 1.53.1 -> 1.54.1 (RUSTSEC-2026-0386, AsyncFd I/O safety) and
ctutils 0.4.2 -> 0.4.5 (RUSTSEC-2026-0385, constant-time masks), so
`cargo deny check advisories` passes. Lockfile only. The re-resolution
also moves several crates' ranged windows-sys requirements onto older
versions already in the lockfile; no package is added or removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@awheeler294
awheeler294 force-pushed the restart-gateway-on-same-port branch from 348fb21 to dff58bb Compare October 23, 2026 20:39
@awheeler294
awheeler294 merged commit dff58bb into master Oct 23, 2026
19 checks passed

This branch was successfully deployed

1 active deployment
github-pages — dff58bbe Deployed Oct 24, 2026 by vinniefalco via deploy #137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gateway A separate product used by PromptForge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants