Skip to content

Add host option for metrics server#63

Open
claytono wants to merge 1 commit into
vladkens:mainfrom
claytono:add-serve-host
Open

Add host option for metrics server#63
claytono wants to merge 1 commit into
vladkens:mainfrom
claytono:add-serve-host

Conversation

@claytono
Copy link
Copy Markdown

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.

Copilot AI review requested due to automatic review settings May 20, 2026 20:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --host CLI option for macmon serve (default 0.0.0.0).
  • Bind the HTTP server to the provided host and pass it through to launchd plist args.
  • Document --host usage 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.

Comment thread src/serve.rs
Comment on lines 141 to 148
<array>
<string>{bin}</string>
<string>serve</string>
<string>--host</string>
<string>{host}</string>
<string>--port</string>
<string>{port}</string>
</array>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/serve.rs Outdated
Comment thread src/serve.rs Outdated
@claytono claytono force-pushed the add-serve-host branch 3 times, most recently from 559da56 to eb2a106 Compare May 21, 2026 15:33
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.
Comment thread src/serve.rs
}

fn serve_url(host: &str, port: u16) -> String {
let host = if matches!(host, "0.0.0.0" | "::") { "localhost" } else { host };
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This preserves the original behavior of printing http://localhost:port if the user doesn't specify and it's bound to all interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants