Restore HTTP-based health server, make it opt-in#6
Conversation
Revert the direct-upstream health probe introduced in #5, which opened a second TCP connection to the Modbus device on every check. Many Modbus devices only accept one concurrent connection, so the probe interfered with normal proxy operation in production. Restore the original passive HTTP health server that checks internal connection state without touching upstream. Make it opt-in via HEALTH_LISTEN so bare-binary users running multiple instances (the root cause of #4) no longer hit port conflicts. The Dockerfile sets HEALTH_LISTEN=:8080 so Docker users get health checks automatically. Closes #4
There was a problem hiding this comment.
Pull request overview
This PR restores the original HTTP-based (passive) health mechanism and makes the health listener opt-in via HEALTH_LISTEN, preventing multi-instance port conflicts while keeping Docker health checks enabled by default.
Changes:
- Add
HEALTH_LISTENto configuration (default empty) and wire it intombproxystartup to conditionally run an internal HTTP/healthserver. - Update
-healthmode to perform an HTTP check against the configured health listener (instead of dialing upstream). - Update Docker image defaults to enable the health listener on
:8080and expose port8080.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/config/config.go | Adds HealthListen to config loaded from HEALTH_LISTEN. |
| internal/config/config_test.go | Extends config tests to cover default empty HealthListen and custom HEALTH_LISTEN. |
| cmd/mbproxy/main.go | Replaces upstream-dial health check with HTTP-based health check and conditionally starts/shuts down health server. |
| cmd/mbproxy/main_test.go | Removes tests for the previous upstream-dial health check implementation. |
| Dockerfile | Enables opt-in health server for Docker via HEALTH_LISTEN=:8080, exposes 8080, and updates the container healthcheck. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: tma <4719+tma@users.noreply.github.com>
Both review items are addressed in commit c9c4fde:
|
Revert the direct-upstream health probe introduced in #5, which opened a second TCP connection to the Modbus device on every check. Many Modbus devices only accept one concurrent connection, so the probe interfered with normal proxy operation in production.
Restore the original passive HTTP health server that checks internal connection state without touching upstream. Make it opt-in via HEALTH_LISTEN so bare-binary users running multiple instances (the root cause of #4) no longer hit port conflicts. The Dockerfile sets HEALTH_LISTEN=:8080 so Docker users get health checks automatically.
Closes #4