Support persistent default listen-addr for spacetime start#4576
Open
0monish wants to merge 1 commit intoclockworklabs:masterfrom
Open
Support persistent default listen-addr for spacetime start#45760monish wants to merge 1 commit intoclockworklabs:masterfrom
0monish wants to merge 1 commit intoclockworklabs:masterfrom
Conversation
Allow \`spacetime start\` to use a project-configured default listen address from \`spacetime.json\`, with proper precedence: CLI flag > config > built-in default. - Add \`has_listen_addr_arg()\` helper to detect explicit --listen-addr or -l - Add \`resolve_listen_addr_from_config()\` to load listening address from config - Inject config-backed address only when user didn't pass explicit CLI flag - Add 12 unit tests covering all argument detection edge cases - Update standalone config documentation with precedence and examples Changes are backward compatible: existing users without config still get 0.0.0.0:3000, and explicit CLI flags continue to take precedence.
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.
Description of Changes
This change allows
spacetime startto use a project-configured default listen address fromspacetime.json.Behavior precedence is now:
spacetime start --listen-addr 127.0.0.1:5000listen-addrfromspacetime.json0.0.0.0:3000Example:
{ "listen-addr": "0.0.0.0:4000" }With that config in place,
spacetime startwill start on0.0.0.0:4000unless--listen-addris passed explicitly.Implementation details:
spacetime startnow checks project config before forwarding to the standalone binary.spacetime.jsondiscovery behavior, including parent-directory search andspacetime.local.jsonlayering.--listen-addrand-lforms so config is only injected when the user did not already provide a listen address.listen-addrbehavior and precedence.This is backward compatible:
0.0.0.0:3000--listen-addrcontinue to behave the sameAPI and ABI breaking changes
None.
This change does not modify any public API or ABI. It only adds an additional configuration source for an existing CLI option while preserving current defaults and CLI override behavior.
Expected complexity level and risk
Complexity: 2/5
This is a small, localized CLI behavior change.
The main interaction point is config precedence between forwarded CLI arguments and project configuration. The implementation is low risk because it:
--listen-addrand-lprecedencespacetime.jsondiscovery and layering behavior rather than introducing a new config systemThe main thing reviewers may want to sanity-check is that the new config-backed behavior only applies when the user did not explicitly pass a listen address.
Testing
Completed:
cargo fmtcargo check -p spacetimedb-clicargo test -p spacetimedb-cli subcommands::start::testscargo clippy -p spacetimedb-cli --all-targetsReviewer checks:
spacetime startwithoutspacetime.jsonand confirm it still binds to0.0.0.0:3000"listen-addr": "0.0.0.0:4000"tospacetime.json, runspacetime start, and confirm it binds to0.0.0.0:4000spacetime start --listen-addr 127.0.0.1:5000with config present and confirm the CLI flag still wins