-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Display an actual TCP port app is bound to #3034
Conversation
@develop7 Good initiative fixing this! I see the CI failures. That happens because the I believe the correct fix is the one that Wolfgang mentioned on #2174 (comment). Basically store the socket on (I don't recall why I didn't make like that on the first place, but seems it should work) |
Yep, on it; the 47df6c2 is more of a PoC |
BTW since |
So |
Not sure whether it's better to store port number along in the |
@develop7 It's starting to look better! Seems you need to add
Yeah, the less state we can keep the better. |
@steve-chavez done and done, but now every single IO test under |
Okay, I've just reproduced the crash in |
Per haskell/network#549 (comment): |
, directory >= 1.2.6 && < 1.4 | ||
exposed-modules: | ||
PostgREST.Unix |
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.
@develop7 Any concerns on windows? Maybe we should allow running tests on windows on CI to be extra sure (can be done on another PR).
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.
That'd be only fair, since Windows got first-class support
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.
We cannot enable all tests on Windows right off the bat, but specs & doctests should be fine
postgrest.cabal
Outdated
, swagger2 >= 2.4 && < 2.9 | ||
, text >= 1.2.2 && < 1.3 | ||
, time >= 1.6 && < 1.12 | ||
, timeit >= 2.0 && < 2.1 | ||
, unordered-containers >= 0.2.8 && < 0.3 | ||
, unix-compat >= 0.6 && < 0.7 |
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.
, unix-compat >= 0.6 && < 0.7 | |
, unix-compat >= 0.5.4 && < 0.6 |
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.
Yup, that should do 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.
That'd did it
also store them in AppState simplify Admin.reachMainApp
a57e6bb
to
77a9345
Compare
src/PostgREST/Admin.hs
Outdated
-- The code for resolving the "*4", "!4", "*6", "!6", "*" special values is taken from | ||
-- https://hackage.haskell.org/package/streaming-commons-0.2.2.4/docs/src/Data.Streaming.Network.html#bindPortGenEx |
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 is no longer the case right? Will remove.
Documents and properly handles the special value of
0
forserver-port
config. Before this PR, the value was passed through and handled by the platform'sgetaddrinfo
implementation, seemingly resulting in binding to a random port. This PR makes it official and binds to random port explicitly.Other changes it introduces:
PostgREST.Unix
, making it the only file with theLANGUAGE CPP
pragma and reducing the amount of indirection. Pretty sure the indirection in question was here on purpose, let me know if that's still the case — tests do pass, things work fine, so I've decided to give it a shot.network
and all Windows released since 5 years ago actually do support Unix domain sockets, so I've taken a chance to prepare code for making use of those: replacedsetFileMode
with its twin function fromunix-compat
and usedNetwork.Socket.isUnixDomainSocketAvailable
to check such sockets' availability in runtime. All that's left to pull the plug is to upgradenetwork
.PostgREST.Unix.installSignalHandlers
more explicit, avoiding potential circular dependency betweenPostgREST.Unix
andPostgREST.AppState
Fixes #2420
Old TODO
TODO:server-port
value of0
; done in server-port can be 0 postgrest-docs#695fix the crash in, presumably,I wasAdmin.reachMainApp
bind
ing a socket, but didn'tlisten
it 😖