Repository navigation
Gateway - Add port-hint cli arg to enable restarting on the same port - #168
Merged
Merged
Conversation
seanpar203
requested changes
Oct 23, 2026
seanpar203
approved these changes
Oct 23, 2026
… 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
force-pushed
the
restart-gateway-on-same-port
branch
from
October 23, 2026 20:39
348fb21 to
dff58bb
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a
--port-hintargument 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
--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 portbind.rsfile that handles the binding logicrunner.rsandthread.rsto use the new codeIt's better for the Gateway to restart on a different port then to fail to restart, so
--port-hintworks on a best-effort basis.User Facing
Nothing uses
--port-hintyet, that comes in the next commit.Since
--port-hintis 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.