-
Notifications
You must be signed in to change notification settings - Fork 28
Add option to allow specifying address to bind to #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Well, you're creating |
305bdbb
to
0cf500c
Compare
Beej's Guide to the rescue. The PR works now 😃 |
04f9d2a
to
d4745f9
Compare
d4745f9
to
1ad0a47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to have a single option e.g. --listen-prometheus=127.0.0.1:9090
. At the moment, it's unclear what should happen if you give e.g. an address and no port. Also, since we have defaults for both host and port, we could also allow just --listen-prometheus
to turn it on without specifying either value.
Will need some compatibility handling for the old port option (and an error if you give both).
app/prometheus_unix.ml
Outdated
let () = Lwt_unix.setsockopt socket SO_REUSEADDR true in | ||
let mode = `TCP (`Socket socket) in | ||
let callback = Server.callback in | ||
let () = Lwt.async (fun () -> Lwt_unix.bind socket addrinfo.ai_addr) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't going to be reliable. It should be done inside thread
, not racing with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the port binding synchronous, this should be a lot more reliable.
ad4b57a
to
9a048dc
Compare
I have attempted to maintain full backwards compatibility while also allowing one to specify the bind address with
--listen-prometheus-addr
which otherwise just defaults to0.0.0.0
.Unfortunately something in conduit_lwt_server throws
Uncaught exception accepting connection: Unix.Unix_error(Unix.EINVAL, "accept", "")
when trying to use this no matter what address is being used.I'm hoping the maintainers of this repo can shed some light on what might be going on otherwise I will open an issue against conduit as I think the implementation in this PR should work.
EDIT: I just came across this bit regarding the use of
cloexec
, thoughts?