Support persistent default listen-addr for spacetime start#4576
Support persistent default listen-addr for spacetime start#45760monish 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.
|
When I can get this feature merged this helps a lot as I am using the spacetimedb and Learning along with that. |
|
|
||
| On Linux and macOS, this directory is by default `~/.local/share/spacetime/data`. On Windows, it's `%LOCALAPPDATA%\SpacetimeDB\data`. | ||
|
|
||
| ## Project-level configuration (`spacetime.json`) |
There was a problem hiding this comment.
This does not belong here, it should be in this document:
There was a problem hiding this comment.
Actually come to think of it, this configuration doesn't belong in spacetime.json at all. That is meant to be checked in to your project repo. This configuration should be in the cli.toml file.
SpacetimeDB/crates/paths/src/lib.rs
Line 63 in 7143ed9
|
@0monish SpacetimeDB/crates/paths/src/lib.rs Line 63 in 7143ed9 |
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