feat(sidecar): make the sidecar installable — CLI, --print-config, anchored data paths
#24
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/installable-cli"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 0.2 of the installer plan (
docs/installer/PLAN.md§5, Phase 0 item 2): "make the sidecar installable — confirm/settle default data paths, and add a way to read back config non-interactively so the installer does not have to scrape logs for the token."Companion docs PR: RunicGateway/docs#84.
Why
The installer has to drive this binary non-interactively, and today it cannot:
PLAN.md§2.4 calls hunting for it the largest "I installed it and nothing happened" failure mode) — is only readable by scraping the startup log or parsing TOML.$UOLINK_CONFIG, which is awkward for a one-off diagnostic run.PLAN.md§2.3, the "working-directory trap").What changed
New CLI (
cli.rs) — four flags, hand-rolled; an argument-parsing dependency would be larger than the code it replaced.An unrecognized argument exits
2rather than silently starting a sidecar that isn't the one asked for.--print-configresolves the configuration exactly as a normal start does — including writing a missing config file and generating a blank auth token — and prints it as JSON on stdout:config_created/token_generatedlet a re-run distinguish read an existing install from provisioned a new one — the values alone can't say.ws_pathcomes from the constant the route is registered with, so the installer's WS URL can't drift from the server's.Data paths settled:
[store].pathanchors to the config file's directory, not the CWD. A unit pinningUOLINK_CONFIG=/etc/runicgateway/sidecar.tomlkeeps its database beside its config instead of in%SystemRoot%\System32or a silently redirected VirtualStore copy. Development is unaffected — undercargo runthe two directories are the same.:memory:andfile:URIs are left alone.sqlite://URL. That spelling is parsed as a URL: it percent-decodes the path and splits it on?, so an installed path containing%20opened a different file. Verified fixed on a directory literally nameda%20b./var/lib/runicgateway/uo-link.dbon a host where nothing has made that directory yet.No platform data directories are compiled in, deliberately: the installer owns layout and pins
UOLINK_CONFIG/UOLINK_DB_PATHin the service definition (PLAN.md§2.3). The anchoring above is what makes a partially configured service (config pinned, db not) land somewhere sane instead of somewhere arbitrary.No protocol change —
PROTOCOL_VERSIONstays3.Verification
All three CI gates pass locally (
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo test --locked).22 unit tests, up from 0 — argument parsing (including
--configwith no value and a typo'd flag), path anchoring,persist_token's three branches, the generated config template round-tripping through the TOML parser, and the--print-configdocument.Smoke-tested against the real binary:
--version,--help, and an unknown flag exiting2.--print-configinto a non-existent directory: created the tree, wrote the config, generated a token, reportedconfig_created: true/token_generated: true. A second run reported bothfalseand the same token.C:\WindowswithUOLINK_CONFIGandUOLINK_DB_PATHpinned to a scratch tree: the db landed exactly where told, including on a directory nameddata 50%.a%20breceived the db literally — the case the URL spelling would have redirected toa b.AI-assisted contribution
Co-Authored-Bytrailer.