Add host option for metrics server#63
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds configurable host binding for the serve command and ensures macOS launchd installation propagates that host value.
Changes:
- Add
--hostCLI option formacmon serve(default0.0.0.0). - Bind the HTTP server to the provided host and pass it through to launchd plist args.
- Document
--hostusage in the README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/serve.rs | Accept host for binding and include it in launchd plist args/logging. |
| src/main.rs | Add --host CLI arg and thread it through launchd()/run(). |
| readme.md | Document --host examples for serve and install flows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <array> | ||
| <string>{bin}</string> | ||
| <string>serve</string> | ||
| <string>--host</string> | ||
| <string>{host}</string> | ||
| <string>--port</string> | ||
| <string>{port}</string> | ||
| </array> |
There was a problem hiding this comment.
I've addressed this by having it resolve the given host at install time. Valid DNS names can't need XML escaping, so we can avoid having to pull in a dep, or hand roll an xml escaping function this way. One down side is that in the tests, it's doing DNS lookups, which does introduce an external dependency. I'm happy to rework this if you'd prefer a different approach.
559da56 to
eb2a106
Compare
Allow macmon serve to bind to a specific host address while preserving the existing 0.0.0.0 default. Persist the selected host when installing the launchd service and document localhost-only examples.
| } | ||
|
|
||
| fn serve_url(host: &str, port: u16) -> String { | ||
| let host = if matches!(host, "0.0.0.0" | "::") { "localhost" } else { host }; |
There was a problem hiding this comment.
This preserves the original behavior of printing http://localhost:port if the user doesn't specify and it's bound to all interfaces.
Allow macmon serve to bind to a specific host address while preserving the existing 0.0.0.0 default. This allows restricting access to localhost only, tailscale, etc.
Persist the selected host when installing the launchd service and document localhost-only examples.